Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
54435 | zhangweiran | 数的划分 | C++ | Accepted | 508 MS | 252 KB | 440 | 2024-10-28 11:52:09 |
#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; }