結果

問題 No.16 累乗の加算
ユーザー むらためむらため
提出日時 2017-07-31 00:56:48
言語 Nim
(2.0.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 610 bytes
コンパイル時間 830 ms
コンパイル使用メモリ 69,588 KB
最終ジャッジ日時 2024-04-27 02:28:29
合計ジャッジ時間 1,195 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 50) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(1, 62) Error: cannot open file: queues

ソースコード

diff #

import sequtils,strutils,strscans,algorithm,math,future,sets,queues,tables
template get():string = stdin.readLine()
template times(n:int,body:untyped): untyped = (for _ in 0..<n: body)

proc power(x,n:int,MOD:int = 0): int =
  if n == 0: return 1
  if n == 1: return x
  let
    pow_2 = power(x,n div 2,MOD)
    odds = (if n mod 2 == 1: x else: 1)
  result = pow_2 * pow_2 * odds
  if MOD > 0: result = result mod MOD

var x,N = 0
(x,N) = get().split().map(parseInt)
let a_seq = get().split().map(parseInt)
const MOD = 1_000_003

var res = 0
for a in a_seq:
  res += power(x,a,MOD)
  res = res mod MOD
echo res
0