結果
| 問題 |
No.162 8020運動
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-03-06 00:15:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,514 bytes |
| コンパイル時間 | 395 ms |
| コンパイル使用メモリ | 55,316 KB |
| 実行使用メモリ | 12,764 KB |
| 最終ジャッジ日時 | 2024-06-24 09:46:25 |
| 合計ジャッジ時間 | 10,947 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | -- * 26 |
ソースコード
#include<iostream>
#include<cstdio>
using namespace std;
const int YEAR = 21;
const int TEETH = 14;
const int MASK = 1 << TEETH;
int limit;
double p[3];
void read() {
int age;
cin >> age;
limit = 80 - age;
int pint0, pint1, pint2;
cin >> pint0 >> pint1 >> pint2;
p[2] = pint0 * 0.01;
p[1] = pint1 * 0.01;
p[0] = pint2 * 0.01;
}
double rec(int year, int mask, double dp[YEAR][MASK]) {
double &ret = dp[year][mask];
if (ret > -0.5) return ret;
if (year == limit) {
return ret = __builtin_popcount(mask);
}
ret = 0;
for (int nexMask = mask; nexMask; nexMask = (nexMask - 1) & mask) {
double mul = 1;
for (int i = 0; i < TEETH; ++i) {
if (!(mask & (1 << i)))
continue;
int nMissing = 0;
nMissing += (i == 0 || !(mask & (1 << (i - 1))));
nMissing += (i == TEETH - 1 || !(mask & (1 << (i + 1))));
if (nexMask & (1 << i)) {
mul *= 1 - p[nMissing];
}
else {
mul *= p[nMissing];
}
}
ret += mul * rec(year + 1, nexMask, dp);
}
return ret;
}
void work() {
static double dp[YEAR][MASK];
for (int i = 0; i < YEAR; ++i)
for (int j = 0; j < MASK; ++j)
dp[i][j] = -1;
printf("%.10lf\n", rec(0, (1 << TEETH) - 1, dp) * 2);
}
int main() {
read();
work();
return 0;
}