codeforces C. k-Tree
思路:dp[i][j]表示和为i,最大值为j的方案数。
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define maxn 100010
#define ll long long
using namespace std;
const int mod=; int n,k,d;
ll dp[][]; int main()
{
scanf("%d%d%d",&n,&k,&d);
for(int i=; i<=n; i++)
{
dp[i][i]=;
}
for(int i=; i<=n; i++)
{
for(int j=; j<=k; j++)
{
for(int x=; x<=k; x++)
{
if(j>=x)
{
dp[i+j][j]+=dp[i][x];
dp[i+j][j]%=mod;
}
else
{
dp[i+j][x]+=dp[i][x];
dp[i+j][x]%=mod;
}
}
}
}
ll ans=;
for(int i=d; i<=k; i++)
{
ans+=dp[n][i];
ans%=mod;
}
printf("%lld\n",ans);
return ;
}
codeforces C. k-Tree的更多相关文章
- Codeforces 343D Water Tree(DFS序 + 线段树)
题目大概说给一棵树,进行以下3个操作:把某结点为根的子树中各个结点值设为1.把某结点以及其各个祖先值设为0.询问某结点的值. 对于第一个操作就是经典的DFS序+线段树了.而对于第二个操作,考虑再维护一 ...
- Problem - D - Codeforces Fix a Tree
Problem - D - Codeforces Fix a Tree 看完第一名的代码,顿然醒悟... 我可以把所有单独的点全部当成线,那么只有线和环. 如果全是线的话,直接线的条数-1,便是操作 ...
- codeforces 570 D. Tree Requests 树状数组+dfs搜索序
链接:http://codeforces.com/problemset/problem/570/D D. Tree Requests time limit per test 2 seconds mem ...
- codeforces 375D:Tree and Queries
Description You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. ...
- Codeforces gym102152 K.Subarrays OR
传送:http://codeforces.com/gym/102152/problem/K 题意:给定$n(n\le10^5)$个数$a_i(a_i\le10^9)$,对于任一个子数组中的数进行或操作 ...
- Codeforces 765 E. Tree Folding
题目链接:http://codeforces.com/problemset/problem/765/E $DFS子$树进行$DP$ 大概分以下几种情况: 1.为叶子,直接返回. 2.长度不同的路径长度 ...
- codeforces 1133E K Balanced Teams
题目链接:http://codeforces.com/contest/1133/problem/E 题目大意: 在n个人中找到k个队伍.每个队伍必须满足最大值减最小值不超过5.求满足条件k个队伍人数的 ...
- Codeforces 932.D Tree
D. Tree time limit per test 2 seconds memory limit per test 512 megabytes input standard input outpu ...
- Codeforces 375 D Tree and Queries
Discription You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. ...
- CodeForces 383C Propagating tree
Propagating tree Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces ...
随机推荐
- Ubuntu 14.04 没有system settings的解决方法
在我的Dell Latitude 3330上, 新装的Ubuntu 14.04一切正常,就是没有system settings程序, 以下的命令能够解决: sudo apt-get install u ...
- JBoss 系列十一:JBoss Cluster Framework Demo 介绍
内容概要 JBoss Cluster Framework Demo包括JGruops.JBossCache.Infinispan,我们在随后的系列中会使用和运行这些示例来说明JGroups.JBoss ...
- [AngularJS + Webpack] Requiring Templates
With Angular, most of the time you're specifying a templateUrl for your directives and states/routes ...
- Windows内核之线程的调度,优先级,亲缘性
1 调度 Windows不是实时操作系统,它是抢占式多线程操作系统.在如果全部优先级同样的情况下,CPU对线程的调度原则是每隔20m就会切换到下一个线程,依据Context中的IP和SP来接着运行上次 ...
- MYSQL查询计划KEY_LEN
http://www.innomysql.com/article/25241.html 1 key_len的含义 2 MySQL中key_len计算规则 3 通过key_len分析联合索引 本文首先介 ...
- linux诡异的半连接(SYN_RECV)队列长度
linux诡异的半连接(SYN_RECV)队列长度(一) >>转载请注明来源:飘零的代码 piao2010 ’s blog,谢谢!^_^>>本文链接地址:linux诡异的半连接 ...
- Qt 学习之路:二进制文件读写
在上一章中,我们介绍了有关QFile和QFileInfo两个类的使用.我们提到,QIODevice提供了read().readLine()等基本的操作.同时,Qt 还提供了更高一级的操作:用于二进制的 ...
- (原创)googlemap开发(一)
听说我们的客户有了外国淫,所以领导问我目前的项目里高德地图和讯飞语音支持英文和英文发音不,按照我以往的经验判断,讯飞支持英语发音和识别英语是没有问题的,但是高德这玩意貌似只有我大天朝的地图吧.于是,找 ...
- java格式处理工具类
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOExceptio ...
- Android开发手记(26) Java多线程的实现
随着多核CPU的发展,多线程编程显得越来越重要,本文将对Java中的多线程编程进行一些简单的探讨. 1.继承Thread类 Java中,线程运行的基本单位是Thread,所以,我们可以通过继承Thre ...