java大数练习

hdu1000

import java.util.Scanner;


public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in=new Scanner(System.in);
        while(in.hasNextInt()){
        int a=in.nextInt();
        int b=in.nextInt();
        System.out.println(a+b);
    }
    }

}

hdu1005

import java.util.Scanner;


public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in =new Scanner(System.in);
        int[] f=new int[100];
        int a=0;
        int b=0;
        int n=0;
        int flag=1;
        int i=0;
        while(in.hasNextInt())
        {
            a=in.nextInt();
            b=in.nextInt();
            n=in.nextInt();
            if(a==0&&b==0&&n==0) break;
            f[1]=1;
            f[2]=1;
            for(i=3;i<=55;i++)
            {
                f[i]=(a*f[i-1]+b*f[i-2])%7;
                //System.out.println(f[i]);
            }
            n%=49;
            System.out.println(f[n]);
        }
    }

}

版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/

posted @ 2015-08-05 15:48  xryz  阅读(96)  评论(0编辑  收藏  举报