QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#215899 | #1777. Fortune From Folly | PhantomThreshold# | WA | 0ms | 3992kb | C++14 | 1.5kb | 2023-10-15 14:17:12 | 2023-10-15 14:17:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long double frac;
namespace gauss{
frac a[533][533],ans[533];
void gauss(int ROW,int COLUMN){
int m=COLUMN,r=1;
int n=ROW;
for (int i=1;i<=m && r<=n;i++){
frac maxx=0;
int maxp=r;
for (int j=r;j<=n;j++){
if (abs(a[j][i])>abs(maxx)){
maxx=a[j][i],maxp=j;
break;
}
}
if (maxx==0) continue;
for (int j=i;j<=m;j++)
swap(a[r][j],a[maxp][j]);
for (int j=r+1;j<=n;j++){
frac t=a[j][i]/a[r][i];
for (int k=i;k<=m;k++){
a[j][k]=a[j][k]-t*a[r][k];
}
}
r++;
}
for (int i=n;i>=1;i--){
for (int j=1;j<=m;j++){
if (a[i][j]!=0){
frac t=a[i][j];
for (int l=j;l<=m;l++) a[i][l]=a[i][l]/t;
for (int k=i-1;k>=1;k--){
frac t=a[k][j]/a[i][j];
for (int l=j;l<=m;l++)
a[k][l]=a[k][l]-t*a[j][l];
}
break;
}
}
}
}
}
int n,k;
frac p;
int main(){
ios_base::sync_with_stdio(false);
cin >> n >> k >> p;
int mx=(1<<n)-1;
for (int mask=0;mask<=mx;mask++){
int nxt0=((mask<<1)&mx)|0;
int nxt1=((mask<<1)&mx)|1;
gauss::a[mask+1][mask+1]+=1.0;
if (__builtin_popcount(mask)>=k){
gauss::a[mask+1][mx+2]=0.0;
}
else{
gauss::a[mask+1][nxt0+1]-=(1-p);
gauss::a[mask+1][nxt1+1]-=p;
gauss::a[mask+1][mx+2]+=1.0;
}
}
gauss::gauss(mx+1,mx+2);
cout << fixed << setprecision(12) << gauss::a[1][mx+2] << "\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3944kb
input:
2 1 0.0006
output:
1666.666666666667
result:
ok found '1666.6666667', expected '1666.6666667', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
2 1 0.0043
output:
232.558139534884
result:
ok found '232.5581395', expected '232.5581395', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
2 1 0.4202
output:
2.379819133746
result:
ok found '2.3798191', expected '2.3798191', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
2 1 0.6729
output:
1.486104919007
result:
ok found '1.4861049', expected '1.4861049', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
2 1 0.9925
output:
1.007556675063
result:
ok found '1.0075567', expected '1.0075567', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
2 1 0.9999
output:
1.000100010001
result:
ok found '1.0001000', expected '1.0001000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
2 2 0.0006
output:
2779444.444444431622
result:
ok found '2779444.4444444', expected '2779444.4444444', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
2 2 0.0072
output:
19429.012345679005
result:
ok found '19429.0123457', expected '19429.0123457', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
2 2 0.0848
output:
150.854396582414
result:
ok found '150.8543966', expected '150.8543966', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
2 2 0.7554
output:
3.076253586480
result:
ok found '3.0762536', expected '3.0762536', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
2 2 0.9980
output:
2.006016040096
result:
ok found '2.0060160', expected '2.0060160', error '0.0000000'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
2 2 0.9995
output:
2.001501000625
result:
ok found '2.0015010', expected '2.0015010', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
3 1 0.0008
output:
1250.000000000000
result:
ok found '1250.0000000', expected '1250.0000000', error '0.0000000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
3 1 0.0063
output:
158.730158730159
result:
ok found '158.7301587', expected '158.7301587', error '0.0000000'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
3 1 0.4356
output:
2.295684113866
result:
ok found '2.2956841', expected '2.2956841', error '0.0000000'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3992kb
input:
3 1 0.5963
output:
1.677008217340
result:
ok found '1.6770082', expected '1.6770082', error '0.0000000'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
3 1 0.9947
output:
1.005328239670
result:
ok found '1.0053282', expected '1.0053282', error '0.0000000'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
3 1 0.9997
output:
1.000300090027
result:
ok found '1.0003001', expected '1.0003001', error '0.0000000'
Test #19:
score: -100
Wrong Answer
time: 0ms
memory: 3904kb
input:
3 2 0.0009
output:
1113.110211111111
result:
wrong answer 1st numbers differ - expected: '618672.9645624', found: '1113.1102111', error = '0.9982008'