UVa:10912 Simple Minded Hashing
来源:互联网 发布:mt管理器源码 编辑:程序博客网 时间:2024/06/05 17:26
还是个递推,跟之前一道题很像。注意L大于26的时候输出0.所以数组不需要开太大。
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <vector>#include <map>#include <string>#include <algorithm>#define ll long long#define INF 2139062143#define MAXN 10000//ios::sync_with_stdio(false);using namespace std;int dp[3][30][MAXN+5];int main(){ int L,S,kase=0; while(scanf("%d%d",&L,&S)!=EOF) { if(!L&&!S) break; memset(dp,0,sizeof(dp)); dp[0][0][0]=dp[1][0][0]=1; printf("Case %d: ",++kase); if(L>26) printf("0\n"); else { for(int i=1; i<=26; ++i) for(int j=1; j<=26; ++j) for(int k=0; k<=S; ++k) if(k-i>=0) dp[i&1][j][k]=dp[(i+1)&1][j-1][k-i]+dp[(i+1)&1][j][k]; else dp[i&1][j][k]=dp[(i+1)&1][j][k]; printf("%d\n",dp[0][L][S]); } } return 0;}
0 0
- UVA 10912 Simple Minded Hashing
- UVA 10912 Simple Minded Hashing
- UVa:10912 Simple Minded Hashing
- uva 10912 - Simple Minded Hashing(计数)
- uva 10912 Simple Minded Hashing (DP)
- Uva 10912 Simple Minded Hashing (计数DP)
- 10912 - Simple Minded Hashing
- 10912 - Simple Minded Hashing (dp)
- UVA10912 - Simple Minded Hashing(dp)
- UVa 10014 - Simple calculations
- uva 10014 - Simple calculations
- uva 10014 Simple calculations
- uva 10014 - Simple calculations
- Uva 10014 - Simple calculations
- UVa 10994 - Simple Addition
- UVa 10014 - Simple calculations
- UVA 10994 Simple Addition
- UVA 10014 Simple calculations
- HDU--杭电--1532--Drainage Ditches--最大流
- scala学习及Intellij Idea
- TMX1.4b规范概述
- 数据结构与算法学习笔记01(引言)
- MySQL连接无法解析HOST主机名
- UVa:10912 Simple Minded Hashing
- Photoshop定义画笔选区为空的原因
- linux---signal
- 网络流--ford-fulkerson算法
- Struts2通配符和动态方法调用
- Node.js中文乱码问题解决方法
- strongly-typed language(强类型语言)
- Excel-算术平均分析(差异分析)
- 《现代操作系统》精读与思考笔记 第七章 多媒体