TLE on #5,调A了关
查看原帖
TLE on #5,调A了关
1393791
liuyuxiaozaizai楼主2025/8/2 15:30
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll n,k,ans,a[100005];
void f(ll p,ll t,ll s){
	if (p>k){
		if (s==n){
			ans++;
		}
		return ;
	}
	for (int i=t;i+t<=n;i++){
		f(p+1,i,s+i);
	}
}

int main(){

	ios::sync_with_stdio(false);
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	
	
	cin>>n>>k;
	f(1,1,0);
	cout<<ans;
	return 0;
}
2025/8/2 15:30
加载中...