Nyoj114 a sequence (large number)
- Question 114
- Question Information
- Running result
- Rankings
- Discussion area certain sequence time limit: 3000 MS | memory limit: 65535 KB difficulty: 4
-
Description
-
Series A meets the requirements of An = An-1 + An-2 + An-3, n> = 3
Write a program and specify A0, A1, and A2 to calculate A99.
Hzyqazasdf
Java:
import java.util.*;import java.math.*;public class Main {public static void main(String[] args) {Scanner input=new Scanner(System.in);while(input.hasNext()){BigInteger x=input.nextBigInteger();BigInteger y=input.nextBigInteger();BigInteger z=input.nextBigInteger();BigInteger t=new BigInteger("0");for(int i=3;i<=99;i++){t=(x.add(y)).add(z);x=y;y=z;z=t;}System.out.println(t);}}}
-
Input
-
Input contains multiple rows of data
Each row of data contains three integers: A0, A1, A2 (0 <= A0, A1, A2 <= 100000000)
Data ends with EOF
-
Output
-
The A99 value is output for each input row.
-
Sample Input
-
1 1 1
-
Sample output
-
69087442470169316923566147
-
Source
-
Water problems are not satisfactory in the competition
-
Uploaded