結果
問題 | No.162 8020運動 |
ユーザー | is_eri23 |
提出日時 | 2015-03-08 14:22:27 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 178 ms / 5,000 ms |
コード長 | 3,968 bytes |
コンパイル時間 | 2,444 ms |
コンパイル使用メモリ | 162,904 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 15:55:01 |
合計ジャッジ時間 | 5,583 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 7 ms
6,812 KB |
testcase_01 | AC | 87 ms
6,940 KB |
testcase_02 | AC | 133 ms
6,940 KB |
testcase_03 | AC | 175 ms
6,944 KB |
testcase_04 | AC | 174 ms
6,944 KB |
testcase_05 | AC | 177 ms
6,944 KB |
testcase_06 | AC | 173 ms
6,940 KB |
testcase_07 | AC | 177 ms
6,944 KB |
testcase_08 | AC | 178 ms
6,940 KB |
testcase_09 | AC | 6 ms
6,940 KB |
testcase_10 | AC | 132 ms
6,944 KB |
testcase_11 | AC | 87 ms
6,940 KB |
testcase_12 | AC | 41 ms
6,944 KB |
testcase_13 | AC | 177 ms
6,944 KB |
testcase_14 | AC | 15 ms
6,944 KB |
testcase_15 | AC | 15 ms
6,940 KB |
testcase_16 | AC | 52 ms
6,940 KB |
testcase_17 | AC | 24 ms
6,940 KB |
testcase_18 | AC | 168 ms
6,940 KB |
testcase_19 | AC | 124 ms
6,940 KB |
testcase_20 | AC | 144 ms
6,940 KB |
testcase_21 | AC | 142 ms
6,948 KB |
testcase_22 | AC | 131 ms
6,944 KB |
testcase_23 | AC | 143 ms
6,944 KB |
testcase_24 | AC | 132 ms
6,940 KB |
testcase_25 | AC | 152 ms
6,940 KB |
testcase_26 | AC | 6 ms
6,940 KB |
testcase_27 | AC | 97 ms
6,940 KB |
testcase_28 | AC | 168 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h> #define EPS 1e-9 #define INF 1070000000LL #define MOD 1000000007LL #define fir first #define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++) #define numa(x,a) for(auto x: a) #define ite iterator #define mp make_pair #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define pb push_back #define pf push_front #define sec second #define sz(x) ((int)(x).size()) #define ALL( c ) (c).begin(), (c).end() #define gcd(a,b) __gcd(a,b) #define mem(x,n) memset(x,n,sizeof(x)) #define endl "\n" using namespace std; template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){} template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); } template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; } template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; } template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; } template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; } #define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; } #define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); } #define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); } #define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); } using ll = long long; #define TEETH 14 int A; int goal; double P[3]; double memo[22][TEETH+1]; inline bool bit_stand(int b, int i){ return (b&(1<<i)) ? true : false; } inline double calc2(int b, int i){ bool next1 = true; bool next2 = true; if (i == 0){ next1 = false; next2 = bit_stand(b,i+1); }else if (i == TEETH - 1){ next1 = bit_stand(b,i-1); next2 = false; }else{ next1 = bit_stand(b,i+1); next2 = bit_stand(b,i-1); } if (next1 && next2) { return P[2]; }else if (next1 || next2) { return P[1]; }else{ return P[0]; } } inline double calc(int b, int b2){//b->b2に遷移する確率 double ret = 1; for (int i = 0; i < TEETH; i++) { if (bit_stand(b,i) != bit_stand(b2,i)) {//虫歯になりました ret *= calc2(b,i); }else if(bit_stand(b2,i)){//健康なまま ret *= 1 - calc2(b,i); } } return ret; } inline vector <int> split(int b){//連続したところを切り出す int now = 0; vector <int> ret; for (int i = 0; i < TEETH; i++) { if (bit_stand(b,i)){ now += 1; }else{ if (now > 0) { ret.pb(now); now = 0; } } } if (now > 0) { ret.pb(now); } return ret; } double dp_go(int now, int now_teeth){ if (now == goal) { return now_teeth; } if (memo[now][now_teeth] >= 0) { return memo[now][now_teeth]; } double ret = 0; int bit = (1 << now_teeth) - 1; for(int T=bit; T>0; T=(T-1)&bit){ //TはSの部分集合(S含む、0含まない) auto p = calc(bit,T); auto seq = split(T); numa(x,seq){ ret += p * dp_go(now+1,x); } } return memo[now][now_teeth] = ret; } int main() { cin.tie(0); ios_base::sync_with_stdio(0); cin >> A; rep(i,3){ cin >> P[i]; P[i] /= 100; } rep(i,22){ rep(j,TEETH+1){ memo[i][j] = -1; } } goal = 80-A; //上下の歯は独立と考えて良い cout << fixed << setprecision(10) << 2 * dp_go(0,TEETH) << endl; return 0; }