結果
| 問題 | 
                            No.66 輝け☆全国たこやき杯
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-06-07 13:03:29 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 37 ms / 5,000 ms | 
| コード長 | 547 bytes | 
| コンパイル時間 | 2,460 ms | 
| コンパイル使用メモリ | 196,012 KB | 
| 最終ジャッジ日時 | 2025-01-10 23:47:20 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 10 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         int m; scanf("%d",&m);
      |                ~~~~~^~~~~~~~~
main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         rep(i,n) scanf("%lf",&a[i]), a[i]*=a[i];
      |                  ~~~~~^~~~~~~~~~~~~
            
            ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
	int m; scanf("%d",&m);
	int n=1<<m;
	vector<double> a(n);
	rep(i,n) scanf("%lf",&a[i]), a[i]*=a[i];
	// dp[i][j] = 人 j が i 回戦後に残っている確率
	vector<vector<double>> dp(m+1,vector<double>(n));
	rep(j,n) dp[0][j]=1;
	rep(i,m) rep(j,n) {
		rep(k,n) if(j!=k) {
			int t;
			for(t=m-1;(j>>t&1)==(k>>t&1);t--);
			if(t==i){
				dp[i+1][j]+=dp[i][j]*dp[i][k]*a[j]/(a[j]+a[k]);
			}
		}
	}
	printf("%.9f\n",dp[m][0]);
	return 0;
}