結果
問題 |
No.16 累乗の加算
|
ユーザー |
|
提出日時 | 2019-09-05 11:14:48 |
言語 | Scheme (Gauche-0.9.15) |
結果 |
AC
|
実行時間 | 45 ms / 5,000 ms |
コード長 | 411 bytes |
コンパイル時間 | 109 ms |
コンパイル使用メモリ | 5,248 KB |
実行使用メモリ | 17,280 KB |
最終ジャッジ日時 | 2025-01-03 02:15:25 |
合計ジャッジ時間 | 1,670 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)))