10519 - !! Really Strange !!



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

class Main {

    public static void main(String[] args) throws IOException {
       
        Scanner sc=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        BigInteger p,in,two;
        two=new BigInteger("2");
        while(sc.hasNext())
        {
            in=sc.nextBigInteger();
            p=in.pow(2);
            if(in.compareTo(BigInteger.ZERO)==0)
                System.out.println("1");
            else if(in.compareTo(BigInteger.ONE)==0)
                System.out.println("2");
            else
                System.out.println((p.subtract(in)).add(two));
        }
       
       
       
    }

}
SHARE

Amit Ghosh

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment