您的位置:首页 > 其它

uva10198 Counting

2012-09-25 11:52 190 查看
//规律 test
=2*test[n-1]+test[n-2]+test[n-3]
//第一次用java写代码 感觉挺别扭 大数运算。
import java.math.*;
import java.util.Scanner;
public class Main {
public static void main(String args[]){
BigInteger test[];
test=new BigInteger[1002];
test[1]=new BigInteger("2");
test[2]=new BigInteger("5");
test[3]=new BigInteger("13");
for(int i=4;i<=1000;i++){
BigInteger ans=((test[i-1].add(test[i-1])).add(test[i-2])).add(test[i-3]);//公式
test[i]=ans;
}
Scanner cin=new Scanner(System.in);
int n;
while(cin.hasNext()){
n=cin.nextInt();
System.out.println(test
);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: