找规律 UVALive 6506 Padovan Sequence

 

题目传送门

 1 /*
 2     找规律:看看前10项就能看出规律,打个表就行了。被lld坑了一次:(
 3 */
 4 #include 
 5 #include 
 6 #include 
 7 #include 
 8 #include 
 9 #include <string>
10 #include 
11 #include 
12 #include 
13 #include <set>
14 #include 
15 #include 
16 using namespace std;
17 
18 typedef long long ll;
19 const int MAXN = 1e2 + 10;
20 const int INF = 0x3f3f3f3f;
21 ll dp[MAXN];
22 
23 void solve(void)
24 {
25     dp[1] = dp[2] = dp[3] = 1;
26     dp[4] = dp[5] = 2;    dp[6] = 3;
27     for (int i=7; i<=100; ++i)
28     {
29         dp[i] = dp[i-1] + dp[i-5];
30     }
31 }
32 
33 int main(void)        //UVALive 6506 Padovan Sequence
34 {
35 //    freopen ("G.in", "r", stdin);
36 
37     solve ();
38     int t;    scanf ("%d", &t);
39     while (t--)
40     {
41         int n;    scanf ("%d", &n);
42         printf ("%lld\n", dp[n]);
43     }
44 
45     return 0;
46 }

 

转载于:https://www.cnblogs.com/Running-Time/p/4592480.html

你可能感兴趣的:(找规律 UVALive 6506 Padovan Sequence)