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;
}
时间: 2024-11-05 23:51:24

HDU 6146 Pokémon GO DP,计数的相关文章

2017&quot;百度之星&quot;程序设计大赛 - 复赛1003&amp;&amp;HDU 6146 Pok&#233;mon GO【数学,递推,dp】

Pokémon GO Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 171    Accepted Submission(s): 104 Problem Description 众所周知,度度熊最近沉迷于 Pokémon GO. 今天它决定要抓住所有的精灵球! 为了不让度度熊失望,精灵球已经被事先放置在一个2*N的格子上,每一个格子上都

hdu 6146 Pok&#233;mon GO (计数)

Problem Description 众所周知,度度熊最近沉迷于 Pokémon GO. 今天它决定要抓住所有的精灵球!为了不让度度熊失望,精灵球已经被事先放置在一个2*N的格子上,每一个格子上都有一个精灵球.度度熊可以选择任意一个格子开始游戏,抓捕格子上的精灵球,然后移动到一个相邻的至少有一个公共点的格子上继续抓捕. 例如,(2, 2) 的相邻格子有(1, 1), (2, 1) 和 (1, 2) 等等.现在度度熊希望知道将所有精灵球都抓到并且步数最少的方案数目. 两个方案被认为是不同,当且仅

HDU 4055 The King’s Ups and Downs(DP计数)

题意:国王的士兵有n个,每个人的身高都不同,国王要将他们排列,必须一高一矮间隔进行,即其中的一个人必须同时高于(或低于)左边和右边.问可能的排列数.例子有1千个,但是最多只算到20个士兵,并且20个的情况的答案已给出. 思路:是此题HDU 4055 Number String(DP计数) 的简单版,所以看此题解就行了.数量较小,可以预先算出来.要同时考虑 <><>和><><这样的两种情况. 1 #include <iostream> 2 #inc

动态规划(DP计数):HDU 5116 Everlasting L

Matt loves letter L. A point set P is (a, b)-L if and only if there exists x, y satisfying: P = {(x, y), (x + 1, y), . . . , (x + a, y), (x, y + 1), . . . , (x, y + b)}(a, b ≥ 1) A point set Q is good if and only if Q is an (a, b)-L set and gcd(a, b)

HDU 4960 (水dp)

Another OCD Patient Problem Description Xiaoji is an OCD (obsessive-compulsive disorder) patient. This morning, his children played with plasticene. They broke the plasticene into N pieces, and put them in a line. Each piece has a volume Vi. Since Xi

HDU 1087 &amp;&amp; POJ 2533(DP,最长上升子序列).

~~~~ 两道题的意思差不多,HDU上是求最长上升子序列的和,而POJ上就的是其长度. 貌似还有用二分写的nlogn的算法,不过这俩题n^2就可以过嘛.. ~~~~ 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1087 http://poj.org/problem?id=2533 ~~~~ HDU1087: #include<cstdio> #include<cstring> #include<algorithm> #

hdu 2296 aC自动机+dp(得到价值最大的字符串)

Ring Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3180    Accepted Submission(s): 1033 Problem Description For the hope of a forever love, Steven is planning to send a ring to Jane with a rom

hdu 2457 AC自动机+dp

DNA repair Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2004    Accepted Submission(s): 1085 Problem Description Biologists finally invent techniques of repairing DNA that contains segments c

[ACM] hdu 3555 Bomb (数位DP,统计1-N中含有“49”的总数)

Bomb Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 7187 Accepted Submission(s): 2512 Problem Description The counter-terrorists found a time bomb in the dust. But this time the terrorists impro