|
|
back to boardNo subject Posted by Enigma 4 Nov 2010 15:59 Edited by author 04.11.2010 16:04 I got AC !!! Posted by Enigma 4 Nov 2010 16:10 MyCode in Java : int k = sc.nextInt(); int n = sc.nextInt(); int z = 0; s = new BigInteger("0"); int[] a = new int[] {1,2,3,5,7,11,13,17,19,23}; int[] b = new int[]{1,6,10,14,15,21,22}; sn = new BigInteger("0"); for (int j = 1; j <=9; j++) { z = n/a[j]; if (z>=k) { almashtirishlar(z,k); s = s.add(sn); }else break; } for (int i = 1; i <=6; i++) { z = n/b[i]; if (z>=k){ almashtirishlar(z, k); s = s.subtract(sn); }else break; } if(s.compareTo(new BigInteger("10000"))<0)System.out.println(s); else System.out.println(10000); } public static void almashtirishlar(int q,int kk) { BigInteger s1 = new BigInteger("1"); for (int i = 2; i <=q; i++) { s1 = s1.multiply(new BigInteger(i+"")); } BigInteger s2 = new BigInteger("1"); for (int i = 2; i <=kk; i++) { s2 = s2.multiply(new BigInteger(i+"")); } BigInteger s3 = new BigInteger("1"); for (int i = 2; i <=q-kk; i++) { s3 = s3.multiply(new BigInteger(i+"")); } sn = s1.divide(s2.multiply(s3)); } } Hello Posted by Enigma 4 Nov 2010 16:11 |
|
|