結果

問題 No.1343 Dividing Digit
ユーザー ixTL255ixTL255
提出日時 2023-01-02 15:55:25
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 11,404 ms
コンパイル使用メモリ 393,080 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-27 00:53:24
合計ジャッジ時間 13,419 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable does not need to be mutable
 --> src/main.rs:9:6
  |
9 |     let mut a: Vec<u64> = itr.map(|e| e.parse().unwrap()).collect();
  |         ----^
  |         |
  |         help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

ソースコード

diff #

use std::io::Read;

fn main() {
	let mut s = String::new();
	std::io::stdin().read_to_string(&mut s).ok();
	let mut itr = s.trim().split_whitespace();
	let n: usize = itr.next().unwrap().parse().unwrap();
	let k: u64 = itr.next().unwrap().parse().unwrap();
	let mut a: Vec<u64> = itr.map(|e| e.parse().unwrap()).collect();
	let s = a.iter().sum::<u64>();
	let mut ans = 0;
	for i in 0..n { ans = (ans * k + a[i]) % s;	}
	println!("{}", ans);
}
0