結果
| 問題 |
No.162 8020運動
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2015-03-08 17:39:54 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,583 bytes |
| コンパイル時間 | 677 ms |
| コンパイル使用メモリ | 23,168 KB |
| 実行使用メモリ | 578,288 KB |
| 最終ジャッジ日時 | 2024-06-24 16:05:57 |
| 合計ジャッジ時間 | 4,130 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 3 |
| other | MLE * 26 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:18:17: warning: format ‘%f’ expects argument of type ‘float *’, but argument 2 has type ‘double *’ [-Wformat=]
18 | scanf("%f %f %f\n",&P0,&P1,&P2);
| ~^ ~~~
| | |
| float * double *
| %lf
main.c:18:20: warning: format ‘%f’ expects argument of type ‘float *’, but argument 3 has type ‘double *’ [-Wformat=]
18 | scanf("%f %f %f\n",&P0,&P1,&P2);
| ~^ ~~~
| | |
| float * double *
| %lf
main.c:18:23: warning: format ‘%f’ expects argument of type ‘float *’, but argument 4 has type ‘double *’ [-Wformat=]
18 | scanf("%f %f %f\n",&P0,&P1,&P2);
| ~^ ~~~
| | |
| float * double *
| %lf
main.c:17:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%d\n",&A);
| ^~~~~~~~~~~~~~~~
main.c:18:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%f %f %f\n",&P0,&P1,&P2);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
double table[1<<14][1<<14];
double dp[2][1<<14];
int BitCnt(int s){
int ret=0;
int i;
for(i=0;i<20;i++){
if( ((s>>i)&1)>0 )ret++;
}
return ret;
}
int main(){
double P0,P1,P2;
int A;
scanf("%d\n",&A);
scanf("%f %f %f\n",&P0,&P1,&P2);
P0/=100.0;P1/=100.0;P2/=100.0;
int s,t,i;
for(s=0;s<1<<14;s++){
for(t=0;t<=s;t++){
if((s|t)!=s){
t+=(t&-t)-1;
continue;
}
double p=1.0;
for(i=0;i<14;i++){
if(((s>>i)&1)==0)continue;
if(((t>>i)&1)==0){
if(i==0){
if(((s>>(i+1))&1)==0){
p*=P0;
}else{
p*=P1;
}
}else{
if(((s>>(i+1))&1)==0 && ((s>>(i-1))&1)==0){
p*=P0;
}else if(((s>>(i+1))&1)==1 && ((s>>(i-1))&1)==1){
p*=P2;
}else{
p*=P1;
}
}
}else{
if(i==0){
if(((s>>(i+1))&1)==0){
p*=(1.0-P0);
}else{
p*=(1.0-P1);
}
}else{
if(((s>>(i+1))&1)==0 && ((s>>(i-1))&1)==0){
p*=(1.0-P0);
}else if(((s>>(i+1))&1)==1 && ((s>>(i-1))&1)==1){
p*=(1.0-P2);
}else{
p*=(1.0-P1);
}
}
}
}
table[s][t]=p;
}
}
int now=0,next=1;
for(s=0;s<1<<14;s++)dp[now][s]=0.0;
dp[0][(1<<14)-1]=1.0;
for(i=0;i<80-A;i++){
now=i%2;
next=now^1;
for(s=0;s<1<<14;s++)dp[next][s]=0.0;
for(s=0;s<(1<<14);s++){
for(t=0;t<=s;t++){
if((s|t)!=s){
t+=(t&-t)-1;
continue;
}
dp[next][t]=table[s][t]*dp[now][s];
}
}
}
double e=0;
for(s=0;s<(1<<14);s++){
e+=BitCnt(s)*dp[next][s];
}
printf("%.6f\n",2.0*e);
return 0;
}
kuuso1