Straycat @ 2024-11-02 12:40:18
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main () {
int p[100001][4],n;
double k;
cin>>n>>k;
int ans=0;
for(int i=0;i<=n;i++){
for(int j=0;j<=n-i;j++){
//cout<<i<<" "<<j<<endl;
for(int m=ceil(n*1.0/(n-i-j+1));m<=i+j;m++){
if(round(i*900000.0/n+j*585000.0/n+m*100000.0/n)==k){
p[ans][0]=i;
p[ans][1]=j;
p[ans][2]=n-i-j;
p[ans][3]=m;
ans++;
}
}
}
}
if(ans==0){
cout<<"No solution!";
}else{
cout<<ans<<endl;
for(int i=0;i<ans;i++){
cout<<p[i][0]<<" "<<p[i][1]<<" "<<p[i][2]<<" "<<p[i][3]<<endl;
}
}
return 0;
}
题目U499016,求优化方法
感谢各位大佬
by shensy9102 @ 2024-11-02 13:44:31
@Straycat 用二分查询连击数试试看,