附上AC代码:
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
const double PI = 3.14159265;
const double E = 2.71828182846;
const int mod = 2005;
const int look = 1000;
int fib[look] = {1, 2, 4, 6, 9, 15};
int main()
{
ios::sync_with_stdio(false);
int loop;
for (int i=6; i<=look; i++)
{
fib[i] = (fib[i-1]+fib[i-3]+fib[i-4])%2005;
if (fib[i] == 2 && fib[i-1] == 1)
{
loop = i-1;
break;
}
}
int L;
while (cin >> L)
{
cout << fib[L%loop] << endl;
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/silenceneo/article/details/47679515