加载中...

数列求值

数列求值

题目描述

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

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

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

运行限制

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

提交答案

#include <iostream>
using namespace std;

int main(){
  int a=5,b=9,c=17,t;
  for(int i=8;i<=20190324;i++){
    t=(a+b+c)%10000;
    a=b;
    b=c;
    c=t;
  }
  cout << t << endl;
  return 0;
}
posted @ 2023-02-22 22:31  bujidao1128  阅读(19)  评论(0)    收藏  举报