結果
| 問題 |
No.66 輝け☆全国たこやき杯
|
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2015-08-06 21:11:01 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,366 bytes |
| コンパイル時間 | 507 ms |
| コンパイル使用メモリ | 73,472 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 03:43:22 |
| 合計ジャッジ時間 | 957 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:72:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
72 | scanf("%d",&m);
| ~~~~~^~~~~~~~~
main.cpp:77:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
77 | scanf("%d",&s[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000000009
#define INF 1000000000
#define LLINF 2000000000000000000LL
#define PI 3.1415926536
#define SIZE 1024
int m,s[SIZE],n=1;
double pro[SIZE];
void dfs(int l,int r){
double pro2[SIZE];
if(l==r){
pro[l]=1;
return;
}
dfs(l,(l+r)/2);
dfs((l+r)/2+1,r);
for(int i=l;i<=(l+r)/2;i++){
double p = 0;
for(int j=(l+r)/2+1;j<=r;j++){
p+=(s[i]*s[i])/(double)(s[i]*s[i]+s[j]*s[j])*pro[j];
}
pro2[i]=p*pro[i];
}
for(int i=(l+r)/2+1;i<=r;i++){
double p = 0;
for(int j=l;j<=(l+r)/2;j++){
p+=(s[i]*s[i])/(double)(s[i]*s[i]+s[j]*s[j])*pro[j];
}
pro2[i]=p*pro[i];
}
for(int i=l;i<=r;i++)
pro[i] = pro2[i];
return;
}
int main(){
scanf("%d",&m);
for(int i=0;i<m;i++) n*=2;
for(int i=0;i<n;i++){
scanf("%d",&s[i]);
}
dfs(0,n-1);
printf("%.15lf",pro[0]);
return 0;
}
goodbaton