THU_ACMER @ 2024-09-18 08:32:57
import math
lst = input().split()
n = int(lst[0])
m = float(lst[1])
s = (n**2+n)//2
a = math.ceil(s*m*0.01)
if a > n or s*m*0.01 < 1:
a = -1
print(a)
by shenyibo12200 @ 2024-10-12 20:44:08
@THU_ACMER
鄙人不才有点看不懂您写的Python代码,只能提供一下鄙人写的c++ ACcode
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MANX=1e5;
double n;
double m;
int u=-1;
int main(){
scanf("%lf%lf",&n,&m);
double L=n/((1+n)*n/2);
if(L<(m/100)){
printf("%d",u);
return 0;
}
double ans=1;
double l,q;
for(double i=1;i<=n;i++){
l=i/((1+n)*n/2);
q=(i-1)/((1+n)*n/2);
if(l>=(m/100)&&q<(m/100)){
ans=i;
}
else{
continue;
}
}
printf("%.0lf",ans);
return 0;
}