結果

問題 No.16 累乗の加算
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2018-06-19 20:28:06
言語 Nim
(2.0.2)
結果
RE  
実行時間 -
コード長 392 bytes
コンパイル時間 3,006 ms
コンパイル使用メモリ 69,192 KB
実行使用メモリ 7,208 KB
最終ジャッジ日時 2023-09-13 07:12:44
合計ジャッジ時間 9,745 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils, math

const
  M = 10 ^ 6 + 3
let
  xN, a = stdin.readLine.split.map parseInt
  (x, N) = (xN[0], xN[1])
var
  ttl = newSeq[int](N)

for i, ai in a:
  var j = 0
  while x ^ j < int.high div x:
    j += 1
  let j0 = j - 1

  var y = 1
  for j in 0 ..< (ai div j0):
    y *= ((x ^ j0) mod M) mod M
  y *= x ^ (ai mod j0)
  y = y mod M

  ttl[i] = y

echo ttl.sum mod M
0