結果

問題 No.16 累乗の加算
ユーザー gigurururugigurururu
提出日時 2014-11-29 14:41:19
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 224 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,460 KB
実行使用メモリ 15,348 KB
最終ジャッジ日時 2023-09-08 11:30:53
合計ジャッジ時間 1,953 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,248 KB
testcase_01 AC 84 ms
15,088 KB
testcase_02 AC 84 ms
15,052 KB
testcase_03 AC 79 ms
15,032 KB
testcase_04 AC 84 ms
15,348 KB
testcase_05 AC 80 ms
15,264 KB
testcase_06 AC 79 ms
15,164 KB
testcase_07 AC 80 ms
15,016 KB
testcase_08 AC 80 ms
15,108 KB
testcase_09 AC 78 ms
15,136 KB
testcase_10 AC 78 ms
15,236 KB
testcase_11 AC 78 ms
15,244 KB
testcase_12 AC 79 ms
15,092 KB
testcase_13 AC 79 ms
15,140 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def pow x,n
    ans=1
    e=x
    while n>0
        ans=(ans*e)%1000003 if n&1>0
        n/=2
        e=(e*e)%1000003
    end
    ans
end

x=gets.split[0].to_i
p gets.split.map{|s|pow x,s.to_i}.inject(:+)%1000003
0