Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
10896 jiabokai 数的划分 C++ 通过 460 MS 252 KB 440 2023-03-03 21:39:37

Tests(5/5):


#include<bits/stdc++.h> using namespace std; int n,k,rest,ans,s[7]; void i(){ cin>>n>>k; rest=n; } void dfs(int dep){ if( dep==k+1 ){ if( rest==0 ) ans++; return ; } for(int i=s[dep-1];i<=rest;i++){ s[dep]=i; rest-=i; dfs(dep+1); rest+=i; } } int main(){ i(); s[0]=1; dfs(1); cout<<ans; return 0; }


测评信息: