1 / 3
Nov 2013

i used good algo for Problem : FAST2 ,
but i am getting TLE , i cannot understand where the bug is..?

import java.util.*;
import java.math.*;
class Fast
{
public static void main(String args[])throws Exception
{
    BigInteger n,p,j=new BigInteger("1"),m=new BigInteger("1298074214633706835075030044377087");
    Integer t,x,i;
    Scanner s=new Scanner(System.in);
    t=s.nextInt();
    while(t-->0)
    {
    n=new BigInteger("1");
    x=s.nextInt();
    n=n.shiftLeft(x+1);
    n=n.subtract(j);
    n=n.mod(m);
    System.out.println(n);
    }
    }
}
  • created

    Nov '13
  • last reply

    Nov '13
  • 2

    replies

  • 400

    views

  • 2

    users

It is not possible to get AC with Java as running time is too low .119 as JVM need .10s on pyramid to up, Surly not possible with java.
You can try in python.

Suggested Topics

Want to read more? Browse other topics in JAVA based languages or view latest topics.