結果

問題 No.242 ビンゴゲーム
ユーザー koba-e964koba-e964
提出日時 2015-07-11 13:01:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 893 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 52,920 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 11:06:57
合計ジャッジ時間 1,110 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,376 KB
testcase_01 AC 10 ms
4,376 KB
testcase_02 AC 10 ms
4,380 KB
testcase_03 AC 10 ms
4,380 KB
testcase_04 AC 10 ms
4,380 KB
testcase_05 AC 10 ms
4,380 KB
testcase_06 AC 10 ms
4,376 KB
testcase_07 AC 10 ms
4,380 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 10 ms
4,380 KB
testcase_10 AC 10 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
}
0