結果
問題 |
No.16 累乗の加算
|
ユーザー |
![]() |
提出日時 | 2018-11-15 22:25:19 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 9 ms / 5,000 ms |
コード長 | 644 bytes |
コンパイル時間 | 11,987 ms |
コンパイル使用メモリ | 379,208 KB |
実行使用メモリ | 5,760 KB |
最終ジャッジ日時 | 2024-12-24 14:06:33 |
合計ジャッジ時間 | 12,884 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
use std::io::Read; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); let x: u32 = iter.next().unwrap().parse().unwrap(); iter.next(); let mut answers: Vec<u32> = vec![1]; let mut cur_num: u32 = x; while cur_num != 1 { answers.push(cur_num); cur_num = cur_num * x % 1000003; } let len: usize = answers.len(); let answer = iter .map(|e| e.parse::<usize>().unwrap()) .fold(0, |acc, e| acc + answers[e%len]) % 1000003; println!("{}", answer); }