Winter vacation is not wasted , Youth cannot be wasted . One question a day , Make sure it doesn't feel cold .

Last topic

First see this topic , Kangkang, my first idea is to use recursion , Direct calculation 20190324 This one , Just don't have hands , therefore WA Yes , This is a false demonstration , Let's start with the answer ——4659
#include<iostream> using namespace std; long long dg(int y) { if(y<=3) return
1; else return dg(y-1)+dg(y-2)+dg(y-3); } int main() { int n=20190324;
cout<<dg(n); return 0; }
Found that the computer gave the answer in a few seconds , I can't help being complacent , The computer just bought is the computer just bought , Just good , Take a closer look , No output found .

Look at the question again , If you do that directly , Will certainly exceed long long Scope of , Should we use high precision  , No, the question is just for the last four , So you might as well change your mind , direct %10000
No, that's good , So there was 2.0 edition
#include<iostream> using namespace std; long long dg(int y) { if(y<=3) return
1; else return dg(y-1)%10000+dg(y-2)%10000+dg(y-3)%10000; } int main() { int
n=20190324; cout<<dg(n); return 0; }
I still can't find it , Because recursion is too inefficient , ok , No way out , How can you give up . It is said that the circulation efficiency is higher , Come on , Upper code
#include<iostream> using namespace std; int a[20190330]; int main() { long
long n=20190324; a[1]=a[2]=a[3]=1; for(int i=4;i<=n;i++) {
a[i]=(a[i-1]+a[i-2]+a[i-3])%10000; } cout<<a[n]; return 0; }
okay , direct AC adopt . See you tomorrow. !

Technology
Daily Recommendation
views 1