結果

問題 No.308 素数は通れません
ユーザー 小指が強い人小指が強い人
提出日時 2015-12-11 02:18:05
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 947 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 11,544 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2023-10-13 10:48:16
合計ジャッジ時間 12,610 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,232 KB
testcase_01 AC 81 ms
15,132 KB
testcase_02 AC 73 ms
15,036 KB
testcase_03 AC 74 ms
15,032 KB
testcase_04 AC 75 ms
15,312 KB
testcase_05 AC 77 ms
15,132 KB
testcase_06 AC 78 ms
15,128 KB
testcase_07 AC 74 ms
15,112 KB
testcase_08 AC 76 ms
15,112 KB
testcase_09 AC 74 ms
15,312 KB
testcase_10 AC 73 ms
15,016 KB
testcase_11 AC 72 ms
15,140 KB
testcase_12 AC 74 ms
15,132 KB
testcase_13 AC 75 ms
15,036 KB
testcase_14 WA -
testcase_15 AC 80 ms
15,124 KB
testcase_16 WA -
testcase_17 AC 80 ms
15,252 KB
testcase_18 AC 78 ms
15,128 KB
testcase_19 AC 80 ms
15,120 KB
testcase_20 AC 77 ms
15,112 KB
testcase_21 AC 73 ms
15,032 KB
testcase_22 AC 75 ms
15,028 KB
testcase_23 AC 79 ms
15,112 KB
testcase_24 AC 79 ms
15,112 KB
testcase_25 WA -
testcase_26 AC 79 ms
15,164 KB
testcase_27 AC 75 ms
15,168 KB
testcase_28 AC 77 ms
15,128 KB
testcase_29 WA -
testcase_30 AC 75 ms
15,076 KB
testcase_31 AC 75 ms
15,156 KB
testcase_32 AC 77 ms
15,020 KB
testcase_33 AC 79 ms
15,248 KB
testcase_34 WA -
testcase_35 AC 77 ms
15,168 KB
testcase_36 AC 77 ms
15,140 KB
testcase_37 AC 76 ms
15,220 KB
testcase_38 AC 75 ms
15,044 KB
testcase_39 AC 76 ms
15,144 KB
testcase_40 AC 77 ms
15,220 KB
testcase_41 AC 78 ms
15,256 KB
testcase_42 AC 79 ms
15,188 KB
testcase_43 AC 79 ms
15,040 KB
testcase_44 AC 77 ms
15,144 KB
testcase_45 AC 77 ms
15,028 KB
testcase_46 AC 76 ms
15,316 KB
testcase_47 AC 77 ms
15,316 KB
testcase_48 AC 76 ms
15,032 KB
testcase_49 AC 76 ms
15,252 KB
testcase_50 AC 76 ms
15,088 KB
testcase_51 AC 76 ms
15,192 KB
testcase_52 AC 77 ms
15,164 KB
testcase_53 AC 81 ms
15,216 KB
testcase_54 WA -
testcase_55 WA -
testcase_56 AC 78 ms
15,120 KB
testcase_57 AC 79 ms
15,288 KB
testcase_58 AC 75 ms
15,116 KB
testcase_59 AC 76 ms
15,136 KB
testcase_60 AC 77 ms
15,136 KB
testcase_61 AC 76 ms
15,072 KB
testcase_62 AC 79 ms
15,044 KB
testcase_63 AC 77 ms
15,144 KB
testcase_64 AC 79 ms
15,152 KB
testcase_65 AC 79 ms
15,232 KB
testcase_66 AC 77 ms
15,080 KB
testcase_67 AC 77 ms
15,148 KB
testcase_68 AC 74 ms
15,320 KB
testcase_69 AC 75 ms
15,088 KB
testcase_70 AC 75 ms
15,104 KB
testcase_71 AC 78 ms
15,076 KB
testcase_72 AC 75 ms
15,040 KB
testcase_73 AC 76 ms
15,160 KB
testcase_74 AC 76 ms
15,040 KB
testcase_75 AC 75 ms
15,188 KB
testcase_76 AC 76 ms
15,200 KB
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 AC 80 ms
15,028 KB
testcase_81 AC 79 ms
15,184 KB
testcase_82 WA -
testcase_83 WA -
testcase_84 AC 78 ms
15,116 KB
testcase_85 WA -
testcase_86 AC 79 ms
15,244 KB
testcase_87 AC 76 ms
15,268 KB
testcase_88 WA -
testcase_89 WA -
testcase_90 AC 74 ms
15,120 KB
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 WA -
testcase_96 AC 80 ms
15,232 KB
testcase_97 AC 76 ms
15,028 KB
testcase_98 AC 74 ms
15,288 KB
testcase_99 AC 73 ms
15,120 KB
testcase_100 AC 76 ms
15,088 KB
testcase_101 AC 81 ms
15,084 KB
testcase_102 WA -
testcase_103 AC 79 ms
15,188 KB
testcase_104 AC 77 ms
15,304 KB
testcase_105 AC 78 ms
15,144 KB
testcase_106 AC 80 ms
15,212 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

  class Integer
    def prime?
      n = self.abs()
      return true if n == 2
      return false if n == 1 || n & 1 == 0
      d = n-1
      d >>= 1 while d & 1 == 0
      20.times do 
        a = rand(n-2) + 1
        t = d
        y = ModMath.pow(a,t,n)
        while t != n-1 && y != 1 && y != n-1
          y = (y * y) % n
          t <<= 1
        end
        return false if y != n-1 && t & 1 == 0
      end
      return true
    end
  end
  
  module ModMath
    def ModMath.pow(base, power, mod)
      result = 1
      while power > 0
        result = (result * base) % mod if power & 1 == 1
        base = (base * base) % mod
        power >>= 1;
      end
      result
    end
  end
n = gets.to_i
a = [4, 6, 8, 9, 10, 15, 16, 22, 12, 14, 20, 21, 24]
b = [3, 5, 7, 7,  7,  7,  7,  7, 11, 13, 19, 19, 23]
a.length.times do |i|
    if a[i] == n
        puts b[i]
        exit
    end
end
if !(n - 8).prime?
    puts 8
else
    puts 14
end
0