結果
| 問題 |
No.162 8020運動
|
| ユーザー |
kei
|
| 提出日時 | 2018-08-28 00:31:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,762 bytes |
| コンパイル時間 | 1,616 ms |
| コンパイル使用メモリ | 167,496 KB |
| 実行使用メモリ | 14,080 KB |
| 最終ジャッジ日時 | 2024-07-05 22:02:15 |
| 合計ジャッジ時間 | 13,348 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 TLE * 1 -- * 1 |
| other | -- * 26 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
/*
<url:https://yukicoder.me/problems/no/162>
問題文============================================================
=================================================================
解説=============================================================
================================================================
*/
typedef long double ld;
ld memo[21][1<<14];
ld P[3];
ld rec(int a,int tooth){
ld& ret = memo[a][tooth];
if(!(ret < 0)) return ret;
ret = 0;
for(int t = 0; t < (1<<14);t++){
if((tooth&t) != tooth) continue;
ld Ptooth = 1;
for(int b = 0; b < 14;b++){
if(!((t>>b)&1)) continue;
int cnt = 2;
if(b == 0){
cnt--;
if(!((t>>1)&1)) cnt--;
}else if(b == 13){
cnt--;
if(!((t>>12)&1)) cnt--;
}else{
if(!((t>>(b-1))&1)) cnt--;
if(!((t>>(b+1))&1)) cnt--;
}
if((tooth>>b)&1) Ptooth *= (1-P[cnt]);
else Ptooth *= P[cnt];
}
ret += (Ptooth*rec(a-1,t));
}
return ret;
}
ld solve(){
fill(*memo,*memo+21*(1<<14),-1);
ld res = 0;
int A; cin >> A; A = 80 - A;
for(int i = 0; i < 3;i++){ cin >> P[i]; P[i]/=100;}
for(int t = 0; t < (1<<14);t++)memo[0][t] = 0;
memo[0][(1<<14)-1] = 1;
for(int t = 0; t < (1<<14);t++) rec(A,t);
for(int tup = 0; tup < (1<<14);tup++){
int up = __builtin_popcount(tup);
for(int tdown = 0; tdown < (1<<14);tdown++){
int down = __builtin_popcount(tdown);
res += (up+down)*memo[A][tup]*memo[A][tdown];
}
}
return res;
}
int main(void) {
cin.tie(0); ios_base::sync_with_stdio(false);
cout << fixed << setprecision(12) << solve() << endl;
return 0;
}
kei