結果

問題 No.162 8020運動
ユーザー 沙耶花沙耶花
提出日時 2021-11-03 11:38:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 986 bytes
コンパイル時間 1,925 ms
コンパイル使用メモリ 200,980 KB
実行使用メモリ 12,960 KB
最終ジャッジ日時 2024-04-21 02:15:59
合計ジャッジ時間 17,819 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 344 ms
6,816 KB
testcase_01 AC 3,415 ms
6,940 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

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){
			
			int S = 1<<14;
			S--;
			S ^= j;
			for(int T = S;true;T = (T-1)&S){
				double v = dp[j];
				rep(k,14){
					if((T>>k)&1)v *= ps[j][k];
					else if(((j>>k)&1)==0) v *= 1.0 - ps[j][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