萌新求助

P1962 斐波那契数列

#include<bits/stdc++.h> using namespace std; int main() { long long x,y,z,n,c=0; cin>>n; x=1; y=1; if(n==1 || n==2) { cout<<1; return 0; } for(long long i=3;i<=n;i++) { c=x+y; z=y; y=c; x=z; } cout<<c%1000000007; return 0; }
by 3346962731SUN @ 2018-12-23 20:01:12


上一页 |