QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#35329 | #968. Extreme Wealth | Froggygua | WA | 4ms | 3840kb | C++17 | 1.4kb | 2022-06-15 09:39:15 | 2022-06-15 09:39:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 2020
typedef long long ll;
const long double PI=acosl(-1.0L);
ll n,m;
long double dp[N][N];
long double Get(ll n){
if(!n)return 0;
return n*logl(n)-n+0.5L*logl(2.0L*n*PI);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.setf(ios::fixed);
cout.precision(10);
cin>>n>>m;
/*
for(int i=0;i<=n;++i){
for(int j=0;j<=m;++j){
if(!i){
dp[i][j]=powl(2.0L,j);
}
else if(!j){
dp[i][j]=powl(2.0L,i);
}
else{
long double X=dp[i-1][j],Y=dp[i][j-1];
dp[i][j]=2.0*X*Y/(X+Y);
}
}
}
if(dp[n][m]>1e9){
cout<<"Extreme Wealth\n";
return 0;
}
cout<<dp[n][m]<<'\n';
return 0;
*/
if(n<=1000000&&m<=1000000){
if(n>m)swap(n,m);
long double ans=1;
int p=1;
for(int i=1;i<=n+m;++i){
ans*=2;
while(ans>1&&p<=n){
ans=ans*p/(m+p);
++p;
}
if(ans>1e20){
cout<<"Extreme Wealth\n";
return 0;
}
}
if(ans>1e9){
cout<<"Extreme Wealth\n";
return 0;
}
cout<<ans<<'\n';
return 0;
}
/*
long double X=logl(2.0L)*(n+m);
long double Y=Get(n+m)-Get(n)-Get(m);
if(X-Y>30||expl(X-Y)>1e9){
cout<<"Extreme Wealth\n";
return 0;
}
cout<<expl(X-Y)<<'\n';
*/
long double ans=sqrtl(PI*n)*(1+1/(8.0L*n));
if(n>m)swap(n,m);
for(ll i=n;i<m;i++){
ans*=2.0L*(i+1)/(n+i+1);
if(ans>1e9){
cout<<"Extreme Wealth\n";
return 0;
}
}
cout<<ans<<'\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3632kb
input:
3 2
output:
3.2000000000
result:
ok OK 3.20000000, real ans = 3.20000000, error = 0.00000000
Test #2:
score: 0
Accepted
time: 2ms
memory: 3840kb
input:
0 29
output:
536870912.0000000000
result:
ok OK 536870912.00000000, real ans = 536870912.00000000, error = 0.00000000
Test #3:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
30 0
output:
Extreme Wealth
result:
ok OK Extreme Wealth, real ans = 1073741824.00000000
Test #4:
score: 0
Accepted
time: 3ms
memory: 3728kb
input:
37 73
output:
5028.4888595832
result:
ok OK 5028.48885958, real ans = 5028.48885958, error = 0.00000000
Test #5:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
10000000000 10000000000
output:
177245.3850927672
result:
ok OK 177245.38509277, real ans = 177245.38509055, error = 0.00000000
Test #6:
score: -100
Wrong Answer
time: 4ms
memory: 3840kb
input:
10000000000 9999412550
output:
989782791.9668422085
result:
wrong answer WA 989782791.96684217, real ans = 989753719.13242424, error = 0.00002937