蓝桥杯数的分解

直接求肯定是超时 之前还没有头绪,看到答案发现取余后加减也是不影响的

#include <iostream>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
//int a[4];

//2019BYQ

int main()
{
    
    
	int t;
	int a=1,b=1,c=1;
	for(int i=4;i<=20190324;i++){
    
    
		t=(a+b+c)%10000;
		a = b;
		b = c;
		c = t;
	}
	cout << t << endl;
	return 0;
	
}

Guess you like

Origin blog.csdn.net/weixin_44044395/article/details/115732000