Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
54822 张思存 数的划分 C++ Accepted 492 MS 248 KB 444 2024-10-31 21:46:36

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; }


Judgement Protocol: