結果

問題 No.162 8020運動
ユーザー 沙耶花沙耶花
提出日時 2021-11-03 11:52:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,673 ms / 5,000 ms
コード長 1,076 bytes
コンパイル時間 2,492 ms
コンパイル使用メモリ 203,756 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 02:34:18
合計ジャッジ時間 33,827 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
6,812 KB
testcase_01 AC 17 ms
6,944 KB
testcase_02 AC 3,502 ms
6,940 KB
testcase_03 AC 966 ms
6,944 KB
testcase_04 AC 575 ms
6,944 KB
testcase_05 AC 3,584 ms
6,940 KB
testcase_06 AC 3,267 ms
6,944 KB
testcase_07 AC 2,433 ms
6,940 KB
testcase_08 AC 3,673 ms
6,940 KB
testcase_09 AC 8 ms
6,944 KB
testcase_10 AC 25 ms
6,944 KB
testcase_11 AC 8 ms
6,940 KB
testcase_12 AC 7 ms
6,944 KB
testcase_13 AC 7 ms
6,940 KB
testcase_14 AC 7 ms
6,944 KB
testcase_15 AC 7 ms
6,940 KB
testcase_16 AC 760 ms
6,940 KB
testcase_17 AC 13 ms
6,940 KB
testcase_18 AC 7 ms
6,940 KB
testcase_19 AC 543 ms
6,944 KB
testcase_20 AC 7 ms
6,940 KB
testcase_21 AC 1,286 ms
6,940 KB
testcase_22 AC 7 ms
6,944 KB
testcase_23 AC 719 ms
6,940 KB
testcase_24 AC 930 ms
6,940 KB
testcase_25 AC 3,023 ms
6,940 KB
testcase_26 AC 7 ms
6,944 KB
testcase_27 AC 2,484 ms
6,944 KB
testcase_28 AC 2,792 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001



int main(){	
	int A;
	cin>>A;
	
	vector<double> p(3);
	rep(i,3){
		cin>>p[i];
		p[i] /= 100.0;
	}
	vector ps(1<<14,vector<double>(14));
	
	rep(i,1<<14){
		rep(j,14){
			int c = 0;
			if(j!=0){
				if(((i>>(j-1))&1)==0)c++;
			}
			if(j!=13){
				if(((i>>(j+1))&1)==0)c++;
			}
			ps[i][j] = p[c];
		}
	}
	
	vector<double> dp(1<<14,0.0);
	dp[0] = 1.0;
	
	rep(i,80-A){
		vector<double> ndp(1<<14,0.0);
		rep(j,1<<14){
			if(dp[j]<1e-16)continue;
			int S = 1<<14;
			S--;
			S ^= j;
			vector<int> t;
			rep(k,14){
				if((S>>k)&1)t.push_back(k);
			}
			for(int T = S;true;T = (T-1)&S){
				double v = dp[j];
				rep(k,t.size()){
					if((T>>t[k])&1)v *= ps[j][t[k]];
					else v *= 1.0 - ps[j][t[k]];
				}
				ndp[j|T] += v;
				
				if(T==0)break;
			}
			
		}
		swap(dp,ndp);
	}
	
	double ans = 0.0;
	rep(i,1<<14){
		ans += (14-__builtin_popcount(i)) * dp[i];
	}
	ans *= 2.0;
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
	return 0;
	
}
0