結果

問題 No.181 A↑↑N mod M
ユーザー takuktakuk
提出日時 2015-04-06 00:48:27
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 11,212 KB
実行使用メモリ 15,616 KB
最終ジャッジ日時 2023-09-17 05:40:14
合計ジャッジ時間 5,982 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
15,156 KB
testcase_01 AC 93 ms
15,164 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 92 ms
15,272 KB
testcase_05 AC 93 ms
15,240 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 92 ms
15,168 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 91 ms
15,092 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 92 ms
15,384 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 94 ms
15,164 KB
testcase_28 WA -
testcase_29 AC 91 ms
15,324 KB
testcase_30 AC 92 ms
15,120 KB
testcase_31 AC 95 ms
15,116 KB
testcase_32 AC 94 ms
15,260 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 93 ms
15,348 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:26: warning: possibly useless use of a variable in void context
Syntax OK

ソースコード

diff #

require 'prime'
def euler(n)
    ps = Array.new
    Prime.each(n) do |p|
        ps.push(p) if n % p == 0
    end
    ret = n
    ps.each do |p|
        ret *= (1.0 - (1.0/p))
    end
    return ret.to_i
end
def modpow(b,e,m)
    res = 1
    while e > 0
        if e & 1 == 1
            res = (res * b) % m
        end
        e >>= 1
        b = (b * b) % m
    end
    res
end
a, n, m = gets.split.map(&:to_i)
p = a
p
(n % euler(m) - 1).times do
    p = modpow(a,p,m)
end
p p
0