結果

問題 No.211 素数サイコロと合成数サイコロ (1)
ユーザー neko_the_shadow
提出日時 2019-05-23 17:39:59
言語 Bash
(Bash 5.2.21)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 424 bytes
コンパイル時間 26 ms
コンパイル使用メモリ 6,688 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 09:47:45
合計ジャッジ時間 880 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/bin/bash

read k
awk -v k=${k} 'BEGIN {
  dice1[1] = 4
  dice1[2] = 6
  dice1[3] = 8
  dice1[4] = 9
  dice1[5] = 10
  dice1[6] = 12

  dice2[1] = 2
  dice2[2] = 3
  dice2[3] = 5
  dice2[4] = 7
  dice2[5] = 11
  dice2[6] = 13

  x = 0
  y = 0
  for (i = 1; i <= length(dice1); i++) {
    for (j = 1; j <= length(dice2); j++) {
      x += 1
      if (dice1[i] * dice2[j] == k) y += 1
    }
  }
  printf("%.20f\n", y / x)
}'
0