- [WFOI - 01] 硬币(coin)
wa#24 求条。。。
- @ 2025-10-13 13:39:37
真要气死了,赛时快要做出来了现在还没a,这题太几把毒瘤了
公式我稍微变了一下形,应该是没问题的
#include<iostream>
#include<cmath>
#define int long long
using namespace std;
int n,k,a;
long double t,dbs,p;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a,t+=a,dbs+=a*a;
t/=n;
p=dbs/n-t*t;
if(!p){
cout<<"No answer!";
return 0;
}
else{
long double d=k/p;
int t=sqrt(d);
if(!t) cout<<1;
else if(abs(p*t*t-k)<=abs(p*(t+1)*(t+1)-k)) cout<<t;
else cout<<t+1;
}
return 0;
}
wrong answer On line 1 column 9, read 8, expected 9.
3 comments
-
C24zhouyanchen LV 3 @ 2025-10-14 14:04:20
-
@ 2025-10-14 13:44:43会不会
abs(p*t*t-k)和abs(p*(t+1)*(t+1)-k有一个是 呢(猜想) -
@ 2025-10-14 13:36:41
- 1
Information
- ID
- 7326
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- # Submissions
- 114
- Accepted
- 4
- Uploaded By