Nyoj114 a sequence (large number)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.