This file contains hidden or 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.ArrayList; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| import java.util.function.Consumer; | |
| import java.util.stream.Collectors; | |
| import BallsInBins; // https://gist.github.com/joriki/d324726fbc3fe4ccdf33628aa02b790c | |
| import BigRational; // https://gist.github.com/joriki/3097452fbb9e1983daf1035f57e72722 | |
| import Binomials; // https://gist.github.com/joriki/5a5c03d2c286effa69584e77a064a6e3 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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; |