#include <bits/stdc++.h> using namespace std; int main(int argc, char** argv) { ios::sync_with_stdio(0); //cin.tie(0); int s[20017]={0};//because 20016 is recycled; s[1]=1; s[2]=2; for(int i=3;i<20017;i++){ s[i]=s[i-1]+s[i-2]; s[i]%=10007; }//DP解題 int n; while(cin>>n){ n%=20016;//because 20016 is recycled;
cout<<s[n]<<endl;
}
return 0;
}
本題觀察後,其為費氏數列