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\n", sum); } return 0; }