UVA 10943 How do you add?
设函数 f(k)(n);
则:
f(1)(n)=1;
f(2)(n)=f(1)(0)+f(1)(1)+f(1)(2)+...+f(1)(n);
f(3)(n)=f(2)(0)+f(2)(1)+f(2)(2)+...+f(2)(n);
.
.
.
f(k)(n)=f(k-1)(0)+f(k-1)(1)+...+f(k-1)(n);
可预处理。
附代码:
#include <iostream>
#include <cstring>
using namespace std; int main (){
int n,k;
int f[][];
memset (f,,sizeof f);
for (int i=;i<=;i++)
f[][i]=;
for (int i=;i<=;i++){
for (int j=;j<=;j++){
for (int o=;o<=j;o++)
f[i][j]=(f[i][j]+f[i-][o])%;
}
}
while (cin>>n>>k&&(n+k)){
cout<<f[k][n]<<endl;
}
return ;
}
最新文章
- MongoDB使用操作
- homework-04 抓瞎
- eclipse 手动安装皮肤
- error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file
- Python中time模块详解
- maven的下载,环境变量配置,和eclipse配置,和IntelliJIDEA配置
- [NIO-2]通道和FileChannel
- day34-python操作redis三
- redis5 集群迁移方案
- Tools - 浏览器Chrome
- LVS:三种负载均衡方式比较
- c#4.0 Task.Factory.StartNew 用法
- javashop组件开发指南
- sql server 2008安装的时候选NT AUTHORITY\NEWORK SERVICE 还是选 NT AUTHORITY\SYSTEM ?
- Mysql试题集锦
- T+固定资产二维码管理(生成,打印)
- SparkR链接mysql数据库(踩坑)
- 6 - Python内置结构 - 字典
- Android静默安装和静默卸载代码
- springBoot整合ecache缓存