java 处理大数据

来源:互联网 发布:很红的网络翻唱歌曲 编辑:程序博客网 时间:2024/04/30 08:47
import java.math.*;import java.util.*;public class Main{    public static void  main(String args[])    {        BigInteger a[]=new BigInteger [1002] ;        a[1]=new BigInteger("1");        a[2]=new BigInteger("2");        a[3]=new BigInteger("4");        a[4]=new BigInteger("7");        a[5]=new BigInteger("12");        for(int i=6;i<1002;i++)            a[i]=a[i-1].add(a[i-2]).add(a[i-4]);        Scanner in=new Scanner(System.in);        int n;        while(in.hasNext())        {            n=in.nextInt();            System.out.println(a[n]);        }    }}

原创粉丝点击