题目描述

本题为填空题,只需要算出结果后,在代码中使用输出语句将所填结果输出即可。

给定数列 1,1,1,3,5,9,17,⋯,从第 4 项开始,每项都是前 3 项的和。

求第 20190324 项的最后 4 位数字。

运行限制

最大运行时间:1s
最大运行内存: 128M

#include <iostream>
using namespace std;

int main()
{
// 请在此输入您的代码
int a = 1, b = 1, c = 1, res;
for (int i = 4; i <= 20190324; ++i) {
res = (a + b + c) % 10000;
a = b;
b = c;
c = res;
}
cout << res;
return 0;
}