链接

第一道URAL题 简单递推

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
using namespace std;
#define LL long long
LL dp[][];
int main()
{
int i,j,n,k,g;
LL ans=;
scanf("%d%d",&n,&k);
for(i = ; i < k ; i++)
dp[][i] = ;
for(i = ; i <= n ; i++)
{
for(g = ; g < k ; g++)
{
if(g!=)
dp[i][g]+=dp[i-][];
for(j = ; j < k ; j++)
{
dp[i][g]+=dp[i-][j];
}
}
}
for(i = ; i < k ; i++)
ans+=dp[n][i];
printf("%lld\n",ans);
return ;
}

URAL1009的更多相关文章

随机推荐

  1. UIMenuController/UIPasteboard(2) UITableView上实用剪贴板

    在UITableView上实用剪贴板有两种方法: 一.在tableView的代理方法中直接有三个有关剪贴板的方法. //某行是否允许show菜单 -(BOOL)tableView:(UITableVi ...

  2. iOS崩溃日志分析

    Incident Identifier: 55864905-937C-4172-B435-2ACA13D3070ECrashReporter Key: b85cab13431711060a5fab55 ...

  3. 使用jQuery调用ASP.NET WebService的简易教程

    鉴于使用Javascript调用Web Service配置略麻烦,所以记录一下. 1. 新建一个Web服务(WebService.asmx) 2. 取消注释// [System.Web.Script. ...

  4. GDI+中发生一般性错误之文件被占用

    有多种原因可能导致这个异常出现,比如创建文件的权限不足.文件被占用等. 这里提供一个使用Stream读取图片避免文件被占用的方法. public Image GetImageFromStream(st ...

  5. 2017 google Round C APAC Test 题解

    题解参考网上的答案,以及我自己的想法. 主要参考网站:http://codeforces.com/blog/entry/47181,http://codeforces.com/blog/entry/4 ...

  6. poj 2533 Longest Ordered Subsequence 最长递增子序列

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4098562.html 题目链接:poj 2533 Longest Ordered Subse ...

  7. leetcode problem 42 -- Trapping Rain Water

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  8. Popen No such file or directory 错误

    File , in reload_config stderr=PIPE, env={"PATH": '', "HOME": "/root"} ...

  9. 2016032101 - eclipse3.7+jdk1.6+maven3.0.5

    公司使用jdk1.6做开发环境,那么使用的eclipse需要下载3.7版本,因为eclipse4以上必须使用jdk1.7及其以上版本. 1.资源下载 jdk1.6需要去oracle官网去下载,可能需要 ...

  10. 2014年度辛星css教程夏季版第五节

    本小节我们讲解css中的”盒模型“,即”box model“,它通常用于在布局的时候使用,这个”盒模型“也有人成为”框模型“,其实原理都一样,它的大致原理是这样的,它把一个HTML元素分为了这么几个部 ...