Attack on Titans


Time Limit: 2 Seconds      Memory Limit: 65536 KB

Over centuries ago, mankind faced a new enemy, the Titans. The difference of power between mankind and their newfound enemy was overwhelming. Soon, mankind was driven to the brink of extinction. Luckily, the surviving humans managed to build three walls: Wall Maria, Wall Rose and Wall Sina. Owing to the protection of the walls, they lived in peace for more than one hundred years.

But not for long, a colossal Titan appeared out of nowhere. Instantly, the walls were shattered, along with the illusory peace of everyday life. Wall Maria was abandoned and human activity was pushed back to Wall Rose. Then mankind began to realize, hiding behind the walls equaled to death and they should manage an attack on the Titans.

So, Captain Levi, the strongest ever human being, was ordered to set up a special operation squad of N people, numbered from 1 to N. Each number should be assigned to a soldier. There are three corps that the soldiers come from: the Garrison, the Recon Corp and the Military Police. While members of the Garrison are stationed at the walls and defend the cities, the Recon Corps put their lives on the line and fight the Titans in their own territory. And Military Police serve the King by controlling the crowds and protecting order. In order to make the team more powerful, Levi will take advantage of the differences between the corps and some conditions must be met.

The Garrisons are good at team work, so Levi wants there to be at least M Garrison members assigned with continuous numbers. On the other hand, members of the Recon Corp are all elite forces of mankind. There should be no more than K Recon Corp members assigned with continuous numbers, which is redundant. Assume there is unlimited amount of members in each corp, Levi wants to know how many ways there are to arrange the special operation squad.

Input

There are multiple test cases. For each case, there is a line containing 3 integers N (0 < N < 1000000), M (0 < M < 10000) and K (0 < K < 10000), separated by spaces.

Output

One line for each case, you should output the number of ways mod 1000000007.

Sample Input

3 2 2

Sample Output

5

Hint

Denote the Garrison, the Recon Corp and the Military Police as G, R and P. Reasonable arrangements are: GGG, GGR, GGP, RGG, PGG.

题解:https://blog.csdn.net/papapa_swust/article/details/77745984

#include <iostream>
#include <cstdio> const int N = +;
const int mod = 1e9+;
typedef long long ll;
int n,m,k; ll dp[N][]; ll _mod(ll x)
{
x %= mod;
x = (x+mod)%mod;
return x;
} ll cal(int u,int v)
{
dp[][]=,dp[][]=,dp[][]=;
for(int i=;i<=n;i++)
{
ll sum= (dp[i-][]+dp[i-][]+dp[i-][])%mod;
dp[i][] = sum;
if(i <= u)
dp[i][] = sum;
//else if(i == u+1)
//dp[i][0] = _mod(sum-1);
else
dp[i][] = _mod(sum - dp[i-u-][]-dp[i-u-][]);
if(i <= v)
dp[i][] = sum;
//else if(i == v+1)
//dp[i][1] = _mod(sum-1);
else
dp[i][] = _mod(sum - dp[i-v-][]-dp[i-v-][]);
}
return _mod(dp[n][]+dp[n][]+dp[n][]);
} int main ()
{ while (scanf("%d%d%d",&n,&m,&k)==)
{
printf("%lld\n",_mod(cal(n,k)-cal(m-,k)));
}
return ;
}

zoj 3747 递推dp的更多相关文章

  1. 递推DP URAL 1167 Bicolored Horses

    题目传送门 题意:k个马棚,n条马,黑马1, 白马0,每个马棚unhappy指数:黑马数*白马数,问最小的unhappy值是多少分析:dp[i][j] 表示第i个马棚放j只马的最小unhappy值,状 ...

  2. 递推DP URAL 1017 Staircases

    题目传送门 /* 题意:给n块砖头,问能组成多少个楼梯,楼梯至少两层,且每层至少一块砖头,层与层之间数目不能相等! 递推DP:dp[i][j] 表示总共i块砖头,最后一列的砖头数是j块的方案数 状态转 ...

  3. 递推DP URAL 1260 Nudnik Photographer

    题目传送门 /* 递推DP: dp[i] 表示放i的方案数,最后累加前n-2的数字的方案数 */ #include <cstdio> #include <algorithm> ...

  4. 递推DP URAL 1353 Milliard Vasya's Function

    题目传送门 /* 题意:1~1e9的数字里,各个位数数字相加和为s的个数 递推DP:dp[i][j] 表示i位数字,当前数字和为j的个数 状态转移方程:dp[i][j] += dp[i-1][j-k] ...

  5. 递推DP URAL 1119 Metro

    题目传送门 /* 题意:已知起点(1,1),终点(n,m):从一个点水平或垂直走到相邻的点距离+1,还有k个抄近道的对角线+sqrt (2.0): 递推DP:仿照JayYe,处理的很巧妙,学习:) 好 ...

  6. 递推DP 赛码 1005 Game

    题目传送门 /* 递推DP:官方题解 令Fi,j代表剩下i个人时,若BrotherK的位置是1,那么位置为j的人是否可能获胜 转移的时候可以枚举当前轮指定的数是什么,那么就可以计算出当前位置j的人在剩 ...

  7. 递推DP HDOJ 5328 Problem Killer

    题目传送门 /* 递推DP: 如果a, b, c是等差数列,且b, c, d是等差数列,那么a, b, c, d是等差数列,等比数列同理 判断ai-2, ai-1, ai是否是等差(比)数列,能在O( ...

  8. hdu1978(递推dp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1978 分析: 递推DP. dp[][]表示可以到达改点的方法数. 刚开始:外循环扫描所有点dp[x][ ...

  9. 递推DP URAL 1031 Railway Tickets

    题目传送门 /* 简单递推DP:读题烦!在区间内的都更新一遍,dp[]初始化INF 注意:s1与s2大小不一定,坑! 详细解释:http://blog.csdn.net/kk303/article/d ...

随机推荐

  1. adb shell dumpsys的用法

    一. 打印出设备中所有service的信息 zh@zh:~$adb shell dumpsys -l (字母l)zh@zh:~$adb shell service list 二.查询到运行的syste ...

  2. 【BZOJ1915】[Usaco2010 Open]奶牛的跳格子游戏 DP+单调队列

    [BZOJ1915][Usaco2010 Open]奶牛的跳格子游戏 Description 奶牛们正在回味童年,玩一个类似跳格子的游戏,在这个游戏里,奶牛们在草地上画了一行N个格子,(3 <= ...

  3. Android EditText光标颜色 与inputType

    1.EditText有一个属性:android:textCursorDrawable,这个属性是用来控制光标颜色的   android:textCursorDrawable="@null&q ...

  4. ThinkPHP分类查询(获取当前分类的子分类,获取父分类,下一级分类)

    获取指定分类的所有子分类ID号 //获取指定分类的所有子分类ID号 function getAllChildcateIds($categoryID){ //初始化ID数组 $array[] = $ca ...

  5. 树形DP求树的直径

    hdu4607 Park Visit Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...

  6. Linux 使用 常识记忆

    1.当系统突然死机需要重启时,打开 命令输入端口,使用快捷键 Shift +Alt +F(1或6)打开 ,然后输入 shutdown -r now 如果提示shutdown need to be ro ...

  7. 封装自己的getClass

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. 170609、Nginx配置文件详细说明

    在此记录下Nginx服务器nginx.conf的配置文件说明, 部分注释收集与网络. #运行用户 user www-data; #启动进程,通常设置成和cpu的数量相等 worker_processe ...

  9. 传智播客京东商城移动web开发

    1.源码笔记 我的源码+笔记(很重要):链接: https://pan.baidu.com/s/1eScieps 密码: 3vyr 感谢传智播客项目相关视频:1.6天链接: https://pan.b ...

  10. ubuntu16.04下用笔记本摄像头和ROS编译运行ORB_SLAM2的单目AR例程

    要编译ORB_SLAM2的ROS例程首先需要安装ROS,以及在ROS下安装usb_cam驱动并调用,最后搭建ORB_SLAM2. 1.ROS的安装 我的电脑安装的是ubuntu16.04系统,所以我安 ...