jpayne@68: package fun; jpayne@68: jpayne@68: import java.util.Locale; jpayne@68: import java.util.Random; jpayne@68: jpayne@68: import shared.Parse; jpayne@68: import shared.Shared; jpayne@68: jpayne@68: public class Chance { jpayne@68: jpayne@68: //Probability of something with a chance of X happening at least Y times in Z chances jpayne@68: public static void main(String[] args){ jpayne@68: jpayne@68: int draws; jpayne@68: int minSuccess; jpayne@68: float prob; jpayne@68: long rounds; jpayne@68: try { jpayne@68: draws = Parse.parseIntKMG(args[0]); jpayne@68: minSuccess = Parse.parseIntKMG(args[1]); jpayne@68: prob = Float.parseFloat(args[2]); jpayne@68: rounds = Parse.parseKMG(args[3]); jpayne@68: } catch (Exception e) { jpayne@68: System.err.println("Chance (int)draws (int)minSuccess (float)prob (int)rounds"); jpayne@68: System.exit(1); jpayne@68: throw new RuntimeException(); jpayne@68: } jpayne@68: jpayne@68: Random randy=Shared.threadLocalRandom(); jpayne@68: jpayne@68: long passes=0; jpayne@68: for(long i=0; i=minSuccess ? 1 : 0); jpayne@68: } jpayne@68: jpayne@68: }