1453: [蓝桥杯2019初赛]数列求值 【水题】有点意思

在这里插入图片描述

http://oj.ecustacm.cn/problem.php?id=1453&csrf=J1ZRnq0e4NfKIP03Vj6vdG7MeBdswHio

题解:
对每一项取10000的模就行了。

#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int a[20190325]={
    
    1,1,1};
int main(void)
{
    
    
    ll sum=0;
    int j;
    for(j=3;j<20190324;j++)
    {
    
    
        a[j]=(a[j-1]+a[j-2]+a[j-3])%10000;
    }
    printf("%d",a[20190323]);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/bettle_king/article/details/115216081