結果

問題 No.16 累乗の加算
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2015-06-03 13:04:34
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 220 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 11,480 KB
実行使用メモリ 15,568 KB
最終ジャッジ日時 2023-09-08 11:37:40
合計ジャッジ時間 2,567 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,148 KB
testcase_01 AC 80 ms
15,092 KB
testcase_02 AC 84 ms
15,396 KB
testcase_03 AC 82 ms
15,224 KB
testcase_04 AC 81 ms
15,312 KB
testcase_05 AC 81 ms
15,140 KB
testcase_06 AC 82 ms
15,236 KB
testcase_07 AC 81 ms
15,276 KB
testcase_08 AC 80 ms
15,408 KB
testcase_09 AC 81 ms
15,568 KB
testcase_10 AC 83 ms
15,368 KB
testcase_11 AC 81 ms
15,296 KB
testcase_12 AC 82 ms
15,348 KB
testcase_13 AC 81 ms
15,300 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

x,n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
dp = Hash.new do |h,k|
    h[k] = (h[(k + 1) / 2] * h[k / 2]) % 1000003
end
dp[0] = 1
dp[1] = x
total = a.inject(0) {|s, v|
    (s + dp[v]) % 1000003
}

puts total
0