結果
問題 | No.242 ビンゴゲーム |
ユーザー |
![]() |
提出日時 | 2017-07-16 14:33:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 4,490 bytes |
コンパイル時間 | 1,353 ms |
コンパイル使用メモリ | 160,736 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 04:16:08 |
合計ジャッジ時間 | 2,067 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long signed int LL;typedef long long unsigned int LU;#define incID(i, l, r) for(int i = (l) ; i < (r); i++)#define incII(i, l, r) for(int i = (l) ; i <= (r); i++)#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)#define decII(i, l, r) for(int i = (r) ; i >= (l); i--)#define inc(i, n) incID(i, 0, n)#define inc1(i, n) incII(i, 1, n)#define dec(i, n) decID(i, 0, n)#define dec1(i, n) decII(i, 1, n)#define inII(v, l, r) ((l) <= (v) && (v) <= (r))#define inID(v, l, r) ((l) <= (v) && (v) < (r))#define PB push_back#define EB emplace_back#define MP make_pair#define FI first#define SE second#define UB upper_bound#define LB lower_bound#define PQ priority_queue#define ALL(v) v.begin(), v.end()#define RALL(v) v.rbegin(), v.rend()#define FOR(it, v) for(auto it = v.begin(); it != v.end(); ++it)#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)template<typename T> bool setmin(T & a, T b) { if(b < a) { a = b; return true; } else { return false; } }template<typename T> bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } }template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }// ---- ----int d[26][13] = {{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 2300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 12650, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 53118, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 176860, 240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 478420, 2280, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 1067895, 13680, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 1984881, 58048, 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 3083468, 184536, 756, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 3998100, 453480, 5820, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 4297872, 874664, 27716, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 3780704, 1328328, 90492, 776, 0, 0, 0, 0, 0, 0, 0, 0, 0 },{ 2664548, 1575736, 211572, 5536, 8, 0, 0, 0, 0, 0, 0, 0, 0 },{ 1456572, 1430612, 358504, 22836, 236, 0, 0, 0, 0, 0, 0, 0, 0 },{ 587935, 958328, 435028, 59608, 2068, 8, 0, 0, 0, 0, 0, 0, 0 },{ 162362, 445644, 363960, 100544, 8883, 180, 2, 0, 0, 0, 0, 0, 0 },{ 27088, 129888, 194820, 106288, 21256, 1336, 24, 0, 0, 0, 0, 0, 0 },{ 2176, 19788, 57992, 64292, 28016, 4612, 220, 4, 0, 0, 0, 0, 0 },{ 48, 1064, 7296, 18136, 18106, 7368, 1064, 48, 0, 0, 0, 0, 0 },{ 0, 0, 186, 1498, 4148, 4528, 1998, 282, 10, 0, 0, 0, 0 },{ 0, 0, 0, 0, 128, 600, 932, 544, 96, 0, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 24, 108, 132, 36, 0, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 16, 0, 0 },{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },};double comb_v[100][100];void init() {inc(i, 100) {inc(j, 100) {comb_v[i][j] = (j == 0 ? 1 : (i == 0 ? 0 : comb_v[i - 1][j] + comb_v[i - 1][j - 1]));}}}double comb(int a, int b) {return (inII(b, 0, a) ? comb_v[a][b] : 0);}int main() {int n;cin >> n;init();double ans = 0.0;incII(i, 0, min(n, 25)) {double a = 0.0, b = 0.0;incII(j, 0, 12) {a += d[i][j] * j;b += d[i][j];}ans += comb(25, i) * comb(99 - 25, n - i) * a / b;}printf("%.8f\n", ans / comb(99, n));//printf("%.8f %.8f\n", ans, comb(99, n));/*inc(i, 20) {inc(j, 20) {printf("%.0f ", comb_v[i][j]);} cout << endl;} cout << endl;*/return 0;}// ----int c[26][13];int f(int i, int j) { return (i * 5 + j); }int b(int bit, int p) { return (bit >> p) % 2; }int bc(int v) {int s = 0;while(v) { s += v % 2; v /= 2; }return s;}int main2() {inc(bit, 1 << 25) {int v = 0, s;inc(i, 5) {s = 0;inc(j, 5) { s += b(bit, f(i, j)); }if(s == 5) { v++; }}inc(j, 5) {s = 0;inc(i, 5) { s += b(bit, f(i, j)); }if(s == 5) { v++; }}s = 0;inc(i, 5) { s += b(bit, f(i, i)); }if(s == 5) { v++; }s = 0;inc(i, 5) { s += b(bit, f(i, 4 - i)); }if(s == 5) { v++; }c[bc(bit)][v]++;}inc(i, 26) { cout << "\t{ ";inc(j, 13) {cout << (j == 0 ? "" : ", ") << c[i][j];} cout << " }, " << endl;}return 0;}