1788: Pell series, 1788pell Series

Source: Internet
Author: User

1788: Pell series, 1788pell Series
1788: Pell Series

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
3000 ms
 
Memory limit:
65536kB
Description
Pell series a1, a2, a3 ,... the definition is as follows: a1 = 1, a2 = 2 ,..., an = 2 * an −1 + an-2 (n> 2 ).
A positive integer k is given, which indicates the value of 32767 In the k-th modulo of the Pell series.
Input
The first row is the number of n groups of test data, followed by n rows of input. Each group of test data occupies one row, including a positive integer k (1 ≤ k <1000000 ).
Output
N rows, each row of output corresponds to an input. The output should be a non-negative integer.
Sample Input
218
Sample output
1408

 1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 #include<cmath> 5 using namespace std; 6 long long int tot=0; 7 long long int a[10000001]; 8 long long int b[10000001]; 9 long long int ans[100000001];10 int main() 11 {12     int n;13     cin>>n;14     for(int i=1;i<=n;i++)15     cin>>a[i];16     b[1]=1;17     b[2]=2;18     for(int i=1;i<=n;i++)19     {20         for(int j=3;j<=a[i];j++)21         {22                 b[j]=(2*b[j-1]+b[j-2])%32767;23                 24         }    25     }26     for(int i=1;i<=n;i++)27     {28         cout<<b[a[i]];29         cout<<endl;30     }31     return 0;32 }

 

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.