fork(3) download
  1. import java.math.*;
  2. class M{
  3. static int c(int n){
  4. BigInteger p, a = p = BigInteger.TEN.pow(10010).multiply(new BigInteger("2"));
  5. for(int i = 1; a.compareTo(BigInteger.ZERO) > 0; p = p.add(a)){
  6. a = a.multiply(new BigInteger(i+"")).divide(new BigInteger((2 * i++ + 1)+""));
  7. }
  8. return (p+"").charAt(n+1) - 48;
  9. }
  10.  
  11. public static void main(String[] a){
  12. System.out.print(c(0)+", ");
  13. System.out.print(c(1)+", ");
  14. System.out.print(c(2)+", ");
  15. System.out.print(c(3)+", ");
  16. System.out.print(c(10)+", ");
  17. System.out.print(c(100)+", ");
  18. System.out.print(c(599)+", ");
  19. System.out.print(c(760)+", ");
  20. System.out.print(c(1000)+", ");
  21. System.out.print(c(10000));
  22. }
  23. }
Success #stdin #stdout 4.76s 711680KB
stdin
Standard input is empty
stdout
1, 4, 1, 5, 8, 8, 2, 4, 3, 5