結果

問題 No.242 ビンゴゲーム
ユーザー naimonon77naimonon77
提出日時 2016-02-14 18:39:21
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,270 bytes
コンパイル時間 1,957 ms
コンパイル使用メモリ 66,804 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-22 05:17:09
合計ジャッジ時間 8,147 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <set>
#include <string>
#include <cstdlib>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int N;
void rand_a(int a[][10]) {
  int i,j;
  rep(j,N) {
    while(1) {
      // 0の代わりに99が読まれないことする
      int b = rand() % 10;
      int c = rand() % 10;
      if(b == 9 && c == 9) continue;
      if(a[b][c] == 1) continue;
      else {
        a[b][c] = 1;
        break;
      }
    }
  }
}
int main(void)
{
  int i,j,k,l;
  int trial_num = 10000000;
  int bingo_cnt = 0;
  cin >> N;
  for(i=0;i<trial_num;i++) {
    int a[10][10] = {0};
    rand_a(a);
    rep(j,5) {
      rep(k,5) if(!a[j][k]) break;
      if(k == 5) bingo_cnt++;
    }
    rep(j,5) {
      rep(k,5) if(!a[k][j]) break;
      if(k == 5) bingo_cnt++;
    }

    rep(j,5)  if(!a[j][j]) break;
    if(j == 5) bingo_cnt++;
    
    rep(j,5) if(!a[4-j][j]) break;
    if(j == 5) bingo_cnt++;
    
  }
  printf("%.20lf\n",(double)bingo_cnt/trial_num);
  return 0;
}
0