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;
}
HDU 6146 Pokémon GO DP,计数的更多相关文章
- HDU 4055 Number String(DP计数)
题意: 给你一个含n个字符的字符串,字符为'D'时表示小于号,字符为“I”时表示大于号,字符为“?”时表示大小于都可以.比如排列 {3, 1, 2, 7, 4, 6, 5} 表示为字符串 DIIDID ...
- 2017"百度之星"程序设计大赛 - 复赛1003&&HDU 6146 Pokémon GO【数学,递推,dp】
Pokémon GO Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- hdu 6146 Pokémon GO (计数)
Problem Description 众所周知,度度熊最近沉迷于 Pokémon GO. 今天它决定要抓住所有的精灵球!为了不让度度熊失望,精灵球已经被事先放置在一个2*N的格子上,每一个格子上都有 ...
- HDU 4055 The King’s Ups and Downs(DP计数)
题意: 国王的士兵有n个,每个人的身高都不同,国王要将他们排列,必须一高一矮间隔进行,即其中的一个人必须同时高于(或低于)左边和右边.问可能的排列数.例子有1千个,但是最多只算到20个士兵,并且20个 ...
- 动态规划(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 ...
- HDU 1011 树形背包(DP) Starship Troopers
题目链接: HDU 1011 树形背包(DP) Starship Troopers 题意: 地图中有一些房间, 每个房间有一定的bugs和得到brains的可能性值, 一个人带领m支军队从入口(房 ...
- hdu 2296 aC自动机+dp(得到价值最大的字符串)
Ring Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- 【POJ1952】逢低吸纳 dp+计数
题目大意:给定一个有 N 个数的序列,求其最长下降子序列的长度,并求出有多少种不同的最长下降子序列.(子序列各项数值相同视为同一种) update at 2019.4.3 题解:求最长下降子序列本身并 ...
- Tetrahedron(Codeforces Round #113 (Div. 2) + 打表找规律 + dp计数)
题目链接: https://codeforces.com/contest/166/problem/E 题目: 题意: 给你一个三菱锥,初始时你在D点,然后你每次可以往相邻的顶点移动,问你第n步回到D点 ...
随机推荐
- 【bzoj1738】[Usaco2005 mar]Ombrophobic Bovines 发抖的牛 Floyd+二分+网络流最大流
题目描述 FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain m ...
- Kingdom and its Cities - CF613D
Meanwhile, the kingdom of K is getting ready for the marriage of the King's daughter. However, in or ...
- AOP拦截+权限验证+返回默认接口对象
接口如:public IList<string> TestAOP(string token); public IMethodReturn Invoke(IMethodInvocation ...
- BZOJ2115:[WC2011]Xor——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=2115 https://www.luogu.org/problemnew/show/P4151 这道 ...
- LOJ2350:[JOI2017/2018决赛]月票购买——题解
https://loj.ac/problem/2350 比较简单的题,为什么我实现得这么sb? 第一个包其实已经给了提示(第一个包的解法就是在S->T所有最短路径上的所有点到V的最短路的最小值. ...
- 放弃采用Mycat的条件
Mycat::一个新颖的数据库中间件产品 设计使用Mycat时: 满足以下任意一条,请考虑放弃使用MyCat 有非分片字段查询 有分页排序 进行表JOIN操作,除非要确保两个表的关联字段具有相同的数据 ...
- 多线程中Local Store Slot(本地存储槽)[转]
1. 使用ThreadStatic特性 ThreadStatic特性是最简单的TLS使用,且只支持静态字段,只需要在字段上标记这个特性就可以了: [ThreadStatic] static str ...
- apache出现You don't have permission to access / on this server. 提示
今天在新的linux上跑原来的代码,使用的虚拟主机的模式进行操作.几个相关的网站放在一个文件里,想法是通过网站列出的目录进行相应的网站进行操作.一切设置完成后,在浏览器中运行出现在You don't ...
- android getpost代码
GetPostUtil public class GetPostUtil { /** * 向指定URL发送GET方法的请求 * * @param url * 发送请求的URL * @param par ...
- SQL_MODE
一 声明 标红部分为重点了解 原文:https://segmentfault.com/a/1190000005936172 二 SQL_MODE参数值 官方手册专门有一节介绍 https://dev. ...