zoukankan      html  css  js  c++  java
  • HDU 6146 Pokémon GO DP,计数

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6146

    题意:~

    解法:原题。。http://blog.csdn.net/y990041769/article/details/21243895

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    const int maxn = 10010;
    LL a[maxn], b[maxn];
    const LL mod = 1e9+7;
    int n;
    
    int main()
    {
        int T;
        scanf("%d", &T);
        while(T--){
            scanf("%d", &n);
            b[1]=1LL;
            for(int i=2; i<=n; i++) b[i]=(b[i-1]*2LL%mod)%mod;
            a[1]=1LL;
            a[2]=6LL;
            for(int i=3; i<=n; i++){
                a[i]=(2LL*a[i-1]+1LL*b[i]+4LL*a[i-2])%mod;
            }
            long long sum = 4*a[n];
            for(int i=2; i<n; i++){
                sum += ((8LL*b[n-i]*a[i-1])%mod+(8LL*a[n-i]*b[i-1])%mod)%mod;
                sum %= mod;
            }
            if(n==1) sum=2;
            printf("%lld
    ", sum);
        }
        return 0;
    }
    
  • 相关阅读:
    既然选择了远方,就只顾风雨兼程!
    slots
    面向对象
    模块和作用域
    偏函数
    python中decorator
    返回函数
    filter, sort
    map/reduce
    开发步骤
  • 原文地址:https://www.cnblogs.com/spfa/p/7481974.html
Copyright © 2011-2022 走看看