zoukankan      html  css  js  c++  java
  • 第二道java

    POJ 3982  大数

    序列
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 7191   Accepted: 3243

    Description

    数列A满足An = An-1 + An-2 + An-3, n >= 3 

    编写程序,给定A0, A1 和 A2, 计算A99

    Input

    输入包含多行数据 

    每行数据包含3个整数A0, A1, A2 (0 <= A0, A1, A2 <= 32767) 
    数据以EOF结束

    Output

    对于输入的每一行输出A99的值

    Sample Input

    1 1 1

    Sample Output

    69087442470169316923566147

    java水过。。。
    //poj3982
    import java.util.*;
    import java.io.*;
    import java.math.*;
    
    public class Main {
        public static void main(String[] args){
            Scanner in=new Scanner(System.in);
            BigInteger x,y,z,w;
            while(in.hasNext()){
                x=in.nextBigInteger();
                y=in.nextBigInteger();
                z=in.nextBigInteger();
                w=new BigInteger("0");
                for(int i=3;i<=99;i++){
                    w=new BigInteger("0");
                    w=w.add(x);
                    w=w.add(y);
                    w=w.add(z);
                    x=y;y=z;z=w;
                }
                System.out.println(w.toString());
            }
        }
    }
    poj3982
    没有AC不了的题,只有不努力的ACMER!
  • 相关阅读:
    准备重启blog。。。
    愿我成功省一。
    [LUOGU]P5502 [JSOI2015]最大公约数
    [LUOGU]P3400 仓鼠窝
    [LUOGU]P5149 会议座位
    OI退役记
    新开博客园~~
    1108 模拟赛
    牛客1102
    题解 CF21B 【Intersection】
  • 原文地址:https://www.cnblogs.com/--560/p/4340854.html
Copyright © 2011-2022 走看看