Description [title]
Fibonacci number Fibonacci sequence refers to the number of columns: a first and a second number of columns is 1, then 2 preceding each number is equal to the sum of the number.
Gives a positive integer a, requires Fibonacci number sequences of a number of the result modulo the number 1000 Yes.
[Enter]
Line 1 is the set of n number of test data, followed by n input lines. Each set of test data representing a line, a positive integer including a (1 ≤ a ≤ 1000000).
[Output]
n lines, each corresponding to an input line of output. The output should be a positive integer, for the Fibonacci number column 1000 of a number of modulo results obtained.
[Sample input]
4 5 2 19 1
[Sample Output]
5 1 181 1 Portal: http: //ybt.ssoier.cn: 8088 / problem_show.php pid = 1188?
#include<iostream> #include<cstring> using namespace std; #define N 1000000+10 int n,a[N]; int main() { a[1]=a[2]=1; for(int i=3;i<=N-1;i++)a[i]=(a[i-1]+a[i-2])%1000; cin>>n; for(int i=1;i<=n;i++){ int as; cin>>as; cout<<a[as]<<endl; } // cout<<a[n]<<endl; }