結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-05 11:14:48 |
| 言語 | Scheme (Gauche-0.9.15) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 5,000 ms |
| コード長 | 411 bytes |
| 記録 | |
| コンパイル時間 | 229 ms |
| コンパイル使用メモリ | 6,528 KB |
| 実行使用メモリ | 17,536 KB |
| 最終ジャッジ日時 | 2026-06-06 10:31:25 |
| 合計ジャッジ時間 | 3,633 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
(define MOD 1000003)
(define (pow x n)
(define y (mod (* x x) MOD))
(define m (div n 2))
(cond ((= n 0) 1)
((= (mod n 2) 1) (mod (* x (pow y m)) MOD))
(else
(pow y m))))
(let* ((pair (map string->number (string-split (read-line) #\space)))
(x (car pair))
(arr (map string->number (string-split (read-line) #\space))))
(print (fold (lambda (n s) (mod (+ (pow x n) s) MOD)) 0 arr)))