This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.math.BigInteger; | |
public class BigRational implements Comparable<BigRational> { | |
public static BigRational ZERO = new BigRational (0); | |
public static BigRational ONE = new BigRational (1); | |
BigInteger num; | |
BigInteger den; | |
public BigRational(long n) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.math.BigInteger; | |
import java.util.Arrays; | |
import java.util.Locale; | |
public class Question3620950 { | |
final static long n = 0x80000000L; | |
public static void main (String [] args) { | |
boolean [] prime = new boolean [(int) (n >> 1)]; // prime [i] : is 2i + 1 prime? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Question3617128 { | |
static long count; | |
public static void main(String [] args) { | |
for (int i = 1,n = 1;;i++,n += i) { | |
count = 0; | |
recurse (new boolean [n],new int [n],new int [i + 1],0); | |
System.out.println(n + " : " + count); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.HashSet; | |
import java.util.Random; | |
import java.util.Set; | |
public class Question3609799 { | |
final static int k = 20; | |
final static int l = 30; | |
final static int n = k + l; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Question2257188 { | |
final static int n = 4; | |
public static void main(String [] args) { | |
double s = 0; | |
double s2 = 0; | |
int [] [] permutations = Permutations.getPermutations(n); | |
for (int [] p : permutations) { | |
int sum = p [0] + 1; | |
for (int i = 1;i < p.length;i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Question3606037 { | |
final static long ntrials = 100000000; | |
final static Random random = new Random(); | |
public static void main(String [] args) { | |
double total = 0; | |
for (long n = 0;n < ntrials;n++) { | |
double sum = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.util.Arrays; | |
import java.util.Comparator; | |
import java.util.HashMap; | |
import java.util.HashSet; | |
import java.util.Map; | |
import java.util.PriorityQueue; | |
import java.util.Queue; | |
import java.util.Set; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package temp; | |
import java.math.BigInteger; | |
import java.util.Arrays; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class Question3602087a { | |
final static int NSUITS = 4; | |
final static int NRANKS = 13; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Question3602087 { | |
final static long ntrials = 10000000; | |
final static Random random = new Random(); | |
final static int NSUITS = 4; | |
final static int NRANKS = 13; | |
final static int NCARDS = NRANKS * NSUITS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.function.Consumer; | |
public class BallsInBins { | |
public static void traverseConfigurations (int nballs,int nbins,Consumer<int []> consumer) { | |
traverseConfigurations(nballs,nbins,Integer.MAX_VALUE,consumer); | |
} | |
public static void traverseConfigurations (int nballs,int nbins,int capacity,Consumer<int []> consumer) { | |
recurse (new int [nbins],nballs,capacity,0,consumer); | |
} |