zoukankan      html  css  js  c++  java
  • 找规律 UVALive 6506 Padovan Sequence

    题目传送门

     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
    ", dp[n]);
    43     }
    44 
    45     return 0;
    46 }
    编译人生,运行世界!
  • 相关阅读:
    kindeditor的使用
    阅读笔记(三)
    阅读笔记(二)
    架构漫谈
    阅读笔记(一)
    hdfs
    暑假周总结八
    暑假周总结七
    暑假周总结六
    暑假周总结五
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4592480.html
Copyright © 2011-2022 走看看