結果

問題 No.1343 Dividing Digit
コンテスト
ユーザー tonyu0
提出日時 2021-01-16 17:58:24
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 3 ms / 2,000 ms
+ 491µs
コード長 526 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 769 ms
コンパイル使用メモリ 190,952 KB
実行使用メモリ 9,888 KB
最終ジャッジ日時 2026-10-01 02:40:49
合計ジャッジ時間 3,187 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::io::*;

fn main() {
    let mut s: String = 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 a: Vec<u64> = (0..n)
        .map(|_| itr.next().unwrap().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