Submission #33238948
Source Code Expand
Copy
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| {
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); }
Submission Info
Submission Time | |
---|---|
Task | D - Multiple of 2019 |
User | bouzuya |
Language | Rust (1.42.0) |
Score | 400 |
Code Size | 756 Byte |
Status | AC |
Exec Time | 20 ms |
Memory | 6204 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 6 ms | 2124 KB |
02.txt | AC | 1 ms | 2028 KB |
03.txt | AC | 1 ms | 2000 KB |
11.txt | AC | 20 ms | 6160 KB |
12.txt | AC | 11 ms | 4924 KB |
13.txt | AC | 1 ms | 2096 KB |
14.txt | AC | 17 ms | 6164 KB |
15.txt | AC | 17 ms | 5580 KB |
16.txt | AC | 4 ms | 2756 KB |
17.txt | AC | 15 ms | 6204 KB |
18.txt | AC | 1 ms | 2020 KB |