Problem Type : Number Theory
import java.math.*;
import java.util.Scanner;
/**
*
* @author Tarequzzaman Khan
*/
public class Main {
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
BigInteger n,m,ans,two;
while(sc.hasNext())
{
n=sc.nextBigInteger();
if( n.equals( BigInteger.ZERO ) ){
System.out.println(1);
continue;
}
ans = (n.multiply(n)).subtract(n);
ans= ans.add(BigInteger.valueOf(2));
System.out.println(""+ans);
}
}
}
import java.math.*;
import java.util.Scanner;
/**
*
* @author Tarequzzaman Khan
*/
public class Main {
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
BigInteger n,m,ans,two;
while(sc.hasNext())
{
n=sc.nextBigInteger();
if( n.equals( BigInteger.ZERO ) ){
System.out.println(1);
continue;
}
ans = (n.multiply(n)).subtract(n);
ans= ans.add(BigInteger.valueOf(2));
System.out.println(""+ans);
}
}
}
No comments:
Post a Comment