蓝桥杯第十届 c/c++ b组 第20190324项

蓝桥杯第十届 c/c++ b组 第20190324项

题目:

给定1,1,1,3,5,9,17…,从第四项开始,没想都是前3项的和,求第20190324项的最后4位数字

答案:4659

代码:
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int a=1;
    int b=1;
    int c=1;
    int s=1;
    while(s!=20190324)
    {
        int t1=b;
        int t2=c;
        c=(a+b+c)%10000;
        a=t1%10000;
        b=t2%10000;
        s++;
    }
    cout<<a<<endl;
    return 0;
}
感谢大家阅读
发布了33 篇原创文章 · 获赞 19 · 访问量 3569

猜你喜欢

转载自blog.csdn.net/qq_42794826/article/details/88885184
今日推荐