結果

問題 No.16 累乗の加算
ユーザー gemmarogemmaro
提出日時 2020-08-07 08:20:49
言語 Ruby
(3.3.0)
結果
MLE  
実行時間 -
コード長 282 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 11,944 KB
実行使用メモリ 799,068 KB
最終ジャッジ日時 2023-10-23 22:27:43
合計ジャッジ時間 7,541 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
16,132 KB
testcase_01 AC 82 ms
16,096 KB
testcase_02 MLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

def solve
  a_max = A.max
  xas = Array.new(a_max + 1, 1)
  (1..a_max).each do |i|
    xas[i] = (xas[i - 1] * X) % L
  end
  A.map { xas[_1] }.sum % L
end

L = 10**6 + 3

X, N = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

puts solve
0