提出 #33238948
ソースコード 拡げる
use std::collections::HashMap;
use proconio::{input, marker::Chars};
fn main() {
input! {
s: Chars,
};
let mut t = vec![];
let mut b = 1_usize;
for s_i in s.iter().copied().rev() {
let d = (s_i as u8 - b'0') as usize;
t.push(d * b);
b *= 10;
b %= 2019;
}
t.reverse();
let cs = std::iter::once(0)
.chain(t.iter().scan(0, |acc, &i| {
*acc += i;
*acc %= 2019;
Some(*acc)
}))
.collect::<Vec<usize>>();
let mut map = HashMap::new();
for cs_i in cs {
*map.entry(cs_i).or_insert(0) += 1;
}
let mut ans = 0;
for &v in map.values() {
ans += v * (v - 1) / 2;
}
println!("{}", ans);
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | D - Multiple of 2019 |
| ユーザ | bouzuya |
| 言語 | Rust (1.42.0) |
| 得点 | 400 |
| コード長 | 756 Byte |
| 結果 | AC |
| 実行時間 | 20 ms |
| メモリ | 6204 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 400 / 400 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 01.txt, 02.txt, 03.txt |
| All | 01.txt, 02.txt, 03.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 01.txt | AC | 6 ms | 2124 KiB |
| 02.txt | AC | 1 ms | 2028 KiB |
| 03.txt | AC | 1 ms | 2000 KiB |
| 11.txt | AC | 20 ms | 6160 KiB |
| 12.txt | AC | 11 ms | 4924 KiB |
| 13.txt | AC | 1 ms | 2096 KiB |
| 14.txt | AC | 17 ms | 6164 KiB |
| 15.txt | AC | 17 ms | 5580 KiB |
| 16.txt | AC | 4 ms | 2756 KiB |
| 17.txt | AC | 15 ms | 6204 KiB |
| 18.txt | AC | 1 ms | 2020 KiB |