結果
| 問題 |
No.66 輝け☆全国たこやき杯
|
| コンテスト | |
| ユーザー |
Ysmr_Ry
|
| 提出日時 | 2014-12-29 14:44:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 589 bytes |
| コンパイル時間 | 116 ms |
| コンパイル使用メモリ | 24,192 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-13 01:02:25 |
| 合計ジャッジ時間 | 4,997 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 RE * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf( "%d", &M );
| ~~~~~^~~~~~~~~~~~
main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf( "%d", S+i );
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
const int MAX_M = 10;
int M, S[MAX_M];
double dp[MAX_M+1][1<<MAX_M];
double calc( int a, int b )
{ return S[a]*S[a]/double(S[a]*S[a]+S[b]*S[b]); }
int main()
{
scanf( "%d", &M );
rep( i, 1<<M )
scanf( "%d", S+i );
rep( j, 1<<M )
dp[0][j] = 1.0;
rep( i, M ) rep( j, 1<<M )
{
int lb = j/(1<<i+1)*(1<<i+1),
ub = lb+(1<<i+1),
mid = lb+ub>>1;
repi( k, j<mid?mid:lb, j<mid?ub:mid )
dp[i+1][j] += dp[i][j]*dp[i][k]*calc( j, k );
}
printf( "%.7f\n", dp[M][0] );
return 0;
}
Ysmr_Ry