| 记录编号 | 360342 | 评测结果 | AAAAA | ||
|---|---|---|---|---|---|
| 题目名称 | 93.[NOIP 2001]数的划分 | 最终得分 | 100 | ||
| 用户昵称 | 是否通过 | 通过 | |||
| 代码语言 | C++ | 运行时间 | 0.042 s | ||
| 提交时间 | 2016-12-29 13:25:03 | 内存使用 | 0.31 MiB | ||
#include<iostream>
#include<cstdio>
using namespace std;
int n,k,s,a[100],sum;
void dfs(int o){
if(o==k&&(n-sum)>=a[o-1])
s++;
else
for(int i=a[o-1];i<=(n-sum)/(k-o+1);i++){
a[o]=i;
sum+=a[o];
dfs(o+1);
sum-=a[o];
}
}
int main(){
freopen("sdhf.in","r",stdin);
freopen("sdhf.out","w",stdout);
cin>>n>>k;
a[0]=1;
dfs(1);
cout<<s;
return 0;
}