Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
10896 | jiabokai | 数的划分 | C++ | Accepted | 460 MS | 252 KB | 440 | 2023-03-03 21:39:37 |
#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; }