数列的前3项都为1,从第4项开始,每项都是其前3项的和:1, 1, 1, 3, 5, 9, 17, … 请你编程求出数列第N项的4位尾数与90000之和。输入一个正整数N,输出所求的和。
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<set>
using namespace std;
#define NUM 10000//符号常量
long long dp[1000000];
int main(){
//freopen("E:\\VSCode_C++\\test.txt","r",stdin);
int n;
cin>>n;
dp[1]=1;
dp[2]=1;
dp[3]=1;
for(int i=4;i<=n;i++){
dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
}
cout<<dp[n]<<endl;
long long x=dp[n]%10000+9000;
cout<<x;
system("pause");
return 0;
}
我的号为什么无缘无故自动提了这么一个问题,抱歉