結果
| 問題 |
No.242 ビンゴゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-07-11 13:01:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 893 bytes |
| コンパイル時間 | 479 ms |
| コンパイル使用メモリ | 55,052 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-08 02:58:07 |
| 合計ジャッジ時間 | 1,176 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 |
ソースコード
#include <iostream>
#include <cstdio>
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
using namespace std;
typedef long long int ll;
int tbl[12] = {0x1f, 0x3e0, 0x7c00, 0xf8000, 0x1f00000,
0x108421, 0x210842, 0x421084, 0x842108, 0x1084210,
0x1041041, 0x111110};
double prob(int n, int p) {
double sum = 1;
REP(i, 0, p) {
sum *= n - i;
sum /= 99 - i;
}
return sum;
}
double p[1 << 12];
int main(void){
int n;
cin >> n;
double sum = 0;
REP(bits, 0, 1 << 12) {
int acc = 0;
REP(i, 0, 12) {
if (bits & 1 << i) {
acc |= tbl[i];
}
}
int pop = __builtin_popcount(acc);
p[bits] = prob(n, pop);
}
for (int i = 4095; i >= 0; --i) {
REP(j, i + 1, 1 << 12) {
if (i & ~j) continue;
p[i] -= p[j];
}
}
REP(i, 0, 1 << 12) {
sum += __builtin_popcount(i) * p[i];
}
printf("%.9f\n", sum);
}