95分求助
查看原帖
95分求助
988978
yhb_luogu楼主2025/6/27 11:34

为啥会95测试

#include<bits/stdc++.h>
using namespace std;
int dp[1005],h,d,c,hdc=4,num[320];
int inti(){
    int i;
    for(i=1;i*i<=h;i++) num[i]=i*i;
    return i;
}
int main(){
	scanf("%d",&h);
	d=inti(),c=d-1;
	for(int i=1;i<=c;i++){
		int cnt=0;
		for(int j=d--;j>0;j--){
			while(num[j]+dp[i]<=h){
				dp[i]+=num[j],cnt++;
				if(cnt>=hdc) goto nxt;
			}
		}nxt:;
		hdc=min(cnt,hdc);
	}
	printf("%d",hdc);
    return 0;
}
2025/6/27 11:34
加载中...