nyoj28 大数阶乘 http://acm.nyist.net/JudgeOnline/problem.php?pid=28
<span style="font-family:KaiTi_GB2312;font-size:18px;">import java.math.BigInteger;
import java.util.*;
import java.io.*;
//求阶乘
public class Main{
public static void main(String[] agrs){
Scanner cin=new Scanner(System.in);
int test=cin.nextInt();
BigInteger ans=BigInteger.ONE;
for(int i=1;i<=test;i++){
ans=ans.multiply(BigInteger.valueOf(i));
}
System.out.println(ans);
}
}</span>
nyoj45 棋盘覆盖 http://acm.nyist.net/JudgeOnline/problem.php?pid=45
<span style="font-family:KaiTi_GB2312;font-size:18px;">import java.math.BigInteger;
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] agrs){
Scanner cin=new Scanner(System.in);
int tc=cin.nextInt();
while(tc-->0){
int n;
n=cin.nextInt();
BigInteger ans=BigInteger.ONE;
for(int i=1;i<=n;i++)
ans=ans.multiply(BigInteger.valueOf(4));
System.out.println(ans.subtract(BigInteger.valueOf(1)).divide(BigInteger.valueOf(3)));
}
}
}
</span>
nyoj73 比较大小 http://acm.nyist.net/JudgeOnline/problem.php?pid=73
<span style="font-family:KaiTi_GB2312;font-size:18px;">import java.math.BigInteger;
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args){
Scanner cin=new Scanner(System.in);
while(cin.hasNext()){
BigInteger a=cin.nextBigInteger();
BigInteger b=cin.nextBigInteger();
if(a.equals(BigInteger.valueOf(0))&&b.equals(BigInteger.valueOf(0)))
break;
int flag=a.compareTo(b);
if(flag==-1)
System.out.println("a<b");
else if(flag==0)
System.out.println("a==b");
else System.out.println("a>b");
}
}
}
</span>
nyoj103 A+B Problem2http://acm.nyist.net/JudgeOnline/problem.php?pid=103
<span style="font-family:KaiTi_GB2312;font-size:18px;">import java.math.BigInteger;
import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]){
Scanner cin=new Scanner(System.in);
int tc=cin.nextInt();
for(int i=1;i<=tc;i++){
BigInteger a,b;
a=cin.nextBigInteger();
b=cin.nextBigInteger();
BigInteger c=a.add(b);
// if(i>1)
// System.out.println();//加上这两行过hdu 1002
System.out.println("Case "+i+":");
System.out.println(a+" + "+b+" = "+c);
}
}
}
</span>
nyoj 114某种序列 http://acm.nyist.net/JudgeOnline/problem.php?pid=114
<span style="font-family:KaiTi_GB2312;font-size:18px;">import java.math.BigInteger;
import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]){
Scanner cin=new Scanner(System.in);
BigInteger a[]=new BigInteger[100];
while(cin.hasNext()){
for(int i=0;i<3;i++)
a[i]=cin.nextBigInteger();
for(int i=3;i<100;i++)
a[i]=a[i-3].add(a[i-2].add(a[i-1]));
System.out.println(a[99]);
}
}
}
</span>
nyoj155 求高精度幂 http://acm.nyist.net/JudgeOnline/problem.php?pid=155
<span style="font-family:KaiTi_GB2312;font-size:18px;">import java.math.BigDecimal;
import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]){
Scanner cin=new Scanner(System.in);
while(cin.hasNext()){
BigDecimal ans=cin.nextBigDecimal();
int n=cin.nextInt();
// for(int i=1;i<=n;i++)
// ans=ans.multiply(ans);
String res=ans.pow(n).stripTrailingZeros().toPlainString();//整数去掉后面的小数点和9=0
if(res.startsWith("0")){
res=res.substring(1);
}
System.out.println(res);
}
}
}
</span>