1 /* 2 找规律:看看前10项就能看出规律,打个表就行了。被lld坑了一次:( 3 */ 4 #include <cstdio> 5 #include <algorithm> 6 #include <iostream> 7 #include <cstring> 8 #include <cmath> 9 #include <string> 10 #include <vector> 11 #include <queue> 12 #include <map> 13 #include <set> 14 #include <ctime> 15 #include <cstdlib> 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 }
时间: 2024-11-06 15:36:54