結果

問題 No.6 使いものにならないハッシュ
ユーザー finefine
提出日時 2016-03-31 20:16:38
言語 Ruby
(3.3.0)
結果
AC  
実行時間 239 ms / 5,000 ms
コード長 448 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 11,336 KB
実行使用メモリ 15,812 KB
最終ジャッジ日時 2023-10-14 22:59:03
合計ジャッジ時間 6,428 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,152 KB
testcase_01 AC 86 ms
15,296 KB
testcase_02 AC 239 ms
15,812 KB
testcase_03 AC 105 ms
15,436 KB
testcase_04 AC 113 ms
15,444 KB
testcase_05 AC 128 ms
15,476 KB
testcase_06 AC 168 ms
15,760 KB
testcase_07 AC 127 ms
15,416 KB
testcase_08 AC 151 ms
15,300 KB
testcase_09 AC 107 ms
15,436 KB
testcase_10 AC 85 ms
15,216 KB
testcase_11 AC 106 ms
15,540 KB
testcase_12 AC 185 ms
15,600 KB
testcase_13 AC 97 ms
15,436 KB
testcase_14 AC 107 ms
15,524 KB
testcase_15 AC 165 ms
15,560 KB
testcase_16 AC 134 ms
15,344 KB
testcase_17 AC 195 ms
15,696 KB
testcase_18 AC 229 ms
15,696 KB
testcase_19 AC 192 ms
15,608 KB
testcase_20 AC 178 ms
15,784 KB
testcase_21 AC 99 ms
15,388 KB
testcase_22 AC 189 ms
15,556 KB
testcase_23 AC 178 ms
15,680 KB
testcase_24 AC 178 ms
15,772 KB
testcase_25 AC 139 ms
15,340 KB
testcase_26 AC 212 ms
15,680 KB
testcase_27 AC 175 ms
15,612 KB
testcase_28 AC 139 ms
15,352 KB
testcase_29 AC 206 ms
15,740 KB
testcase_30 AC 200 ms
15,576 KB
testcase_31 AC 180 ms
15,788 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'

k,n = STDIN.map(&:to_i)
a = []
b = []
max = 0
ans = 0
k.upto(n){|x|
    unless x.prime?
        next
    end
    a.push(x)
    b.push(x % 9)
    tmp = c = 0
    (-1).downto(-9){|i|
        unless b[i]
            break
        end
        if tmp[b[i]] == 0
            tmp |= (1 << b[i])
            c += 1
        else
            break
        end
        }
    if max <= c
        max = c
        ans = a[-c]
    end
    }
p ans
0