思路: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的更多相关文章

  1. Codeforces 343D Water Tree(DFS序 + 线段树)

    题目大概说给一棵树,进行以下3个操作:把某结点为根的子树中各个结点值设为1.把某结点以及其各个祖先值设为0.询问某结点的值. 对于第一个操作就是经典的DFS序+线段树了.而对于第二个操作,考虑再维护一 ...

  2. Problem - D - Codeforces Fix a Tree

    Problem - D - Codeforces  Fix a Tree 看完第一名的代码,顿然醒悟... 我可以把所有单独的点全部当成线,那么只有线和环. 如果全是线的话,直接线的条数-1,便是操作 ...

  3. codeforces 570 D. Tree Requests 树状数组+dfs搜索序

    链接:http://codeforces.com/problemset/problem/570/D D. Tree Requests time limit per test 2 seconds mem ...

  4. codeforces 375D:Tree and Queries

    Description You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. ...

  5. Codeforces gym102152 K.Subarrays OR

    传送:http://codeforces.com/gym/102152/problem/K 题意:给定$n(n\le10^5)$个数$a_i(a_i\le10^9)$,对于任一个子数组中的数进行或操作 ...

  6. Codeforces 765 E. Tree Folding

    题目链接:http://codeforces.com/problemset/problem/765/E $DFS子$树进行$DP$ 大概分以下几种情况: 1.为叶子,直接返回. 2.长度不同的路径长度 ...

  7. codeforces 1133E K Balanced Teams

    题目链接:http://codeforces.com/contest/1133/problem/E 题目大意: 在n个人中找到k个队伍.每个队伍必须满足最大值减最小值不超过5.求满足条件k个队伍人数的 ...

  8. Codeforces 932.D Tree

    D. Tree time limit per test 2 seconds memory limit per test 512 megabytes input standard input outpu ...

  9. Codeforces 375 D Tree and Queries

    Discription You have a rooted tree consisting of n vertices. Each vertex of the tree has some color. ...

  10. CodeForces 383C Propagating tree

    Propagating tree Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces ...

随机推荐

  1. poj 2926 Requirements

    点击打开poj 2926 思路: n维空间计算最远的曼哈顿距离 分析: 1 题目给定n个5维的点,要求最远的曼哈顿距离 2 求最远曼哈顿距离,对于一个n维的空间,其中两点的曼哈顿距离为:|x1-x2| ...

  2. [MODx] Solve cannot upload large file

    If you also run into this problem, dont' worry, here is the solution for you. First: In Modx, go &qu ...

  3. iOS-系统定位功能

    ios系统定位 前期准备 系统定位功能,需要用到框架:CoreLocation/CoreLocation.h, 然后导入文件#import <CoreLocation/CoreLocation. ...

  4. iOS 高仿:花田小憩3.0.1

    前言 断断续续的已经学习Swift一年多了, 从1.2到现在的2.2, 一直在语法之间徘徊, 学一段时间, 工作一忙, 再捡起来隔段时间又忘了.思来想去, 趁着这两个月加班不是特别多, 就决定用swi ...

  5. 【转载】Shared Configuration

    Introduction The Internet changes the ways in which companies handle their day-to-day business and h ...

  6. Couchbase用的端口

    文档首页: http://www.couchbase.com/documentation http://docs.couchbase.com/couchbase-manual-2.2/#prepara ...

  7. 调优系列-tomcat调优

    http://www.360doc.com/content/14/1208/13/16070877_431273418.shtml 使用JMeter对Tomcat进行压力测试与Tomcat性能调优 n ...

  8. WPF Paragraph获取或修改文本内容

    一.说明 Paragraph继承自Block,Block继承自TextElement,在TextElement中 // // 摘要: // 获取表示元素中内容末尾的 System.Windows.Do ...

  9. Adb connect监听指定的主机和端口/Adb监听Visual Studio Emulator for Android模拟器

    语法: adb connect <host>[:<port>] 使用实例: adb connect //如果连接成功则返回 connected to 说明 在使用Visual ...

  10. PrintWriter 和 BufferedWriter 写入文件.

    Ref: should I use PrintWriter to wrap BufferedWriter? The main reason for using PrintWriter is the w ...