結果
問題 | No.2562 数字探しゲーム(緑以下コンver.) |
ユーザー | ぱるま |
提出日時 | 2023-12-02 16:53:48 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,994 bytes |
コンパイル時間 | 12,114 ms |
コンパイル使用メモリ | 380,184 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-19 21:34:41 |
合計ジャッジ時間 | 14,106 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 1 ms
6,816 KB |
コンパイルメッセージ
warning: field `n_cases` is never read --> src/main.rs:22:5 | 21 | struct Problem { | ------- field in this struct 22 | n_cases: usize, | ^^^^^^^ | = note: `#[warn(dead_code)]` on by default
ソースコード
use std::io::stdin; struct TestCase{ m: i64, ds: Vec<i64>, } impl TestCase{ fn solve(&self) -> i64 { let mut digits = vec![]; for (d, cnt) in self.ds.iter().enumerate(){ for _ in 0..*cnt{ digits.push(d as i64); } } let num = digits.iter().copied().fold(0, |acc, x| 10 * acc * x); ((num / self.m) + 1) * self.m } } struct Problem { n_cases: usize, test_cases: Vec<TestCase>, } impl Problem { fn read<R: IProconReader>(mut r: R) -> Problem { let n_cases = r.read_usize_1(); let test_cases = (0..n_cases).map(|_| { let m = r.read_i64_1(); let ds = r.read_vec_i64(); TestCase { m, ds } }).collect(); Problem { n_cases, test_cases } } fn solve(&self) -> Answer { let ans = self.test_cases.iter().map(|test_case| { test_case.solve() }).collect(); Answer { ans } } } #[derive(Clone, Debug, PartialEq, Eq)] struct Answer { ans: Vec<i64>, } impl Answer { fn print(&self) { for r in &self.ans{ println!("{}", r); } } } fn main() { Problem::read(ProconReader::new(stdin().lock())).solve().print(); } #[cfg(test)] mod tests { use super::*; #[allow(dead_code)] fn check(input: &str, expected: Answer) { let actual = Problem::read(ProconReader::new(input.as_bytes())).solve(); assert_eq!(expected, actual); } #[test] fn test_problem() { let _input = " 3 4 " .trim(); // check(_input, Answer { ans: 7 }); } } // ====== snippet ====== #[allow(unused_imports)] use myio::*; pub mod myio { use std::io::BufRead; pub trait IProconReader { fn read_line(&mut self) -> String; fn read_bytes(&mut self) -> Vec<u8> { self.read_line().as_bytes().to_vec() } fn read_any_1<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, { let buf = self.read_line(); buf.parse::<T>().unwrap() } fn read_any_2<T0, T1>(&mut self) -> (T0, T1) where T0: std::str::FromStr, T0::Err: std::fmt::Debug, T1: std::str::FromStr, T1::Err: std::fmt::Debug, { let buf = self.read_line(); let splitted = buf.trim().split(' ').collect::<Vec<_>>(); let a0 = splitted[0].parse::<T0>().unwrap(); let a1 = splitted[1].parse::<T1>().unwrap(); (a0, a1) } fn read_any_3<T0, T1, T2>(&mut self) -> (T0, T1, T2) where T0: std::str::FromStr, T0::Err: std::fmt::Debug, T1: std::str::FromStr, T1::Err: std::fmt::Debug, T2: std::str::FromStr, T2::Err: std::fmt::Debug, { let buf = self.read_line(); let splitted = buf.trim().split(' ').collect::<Vec<_>>(); let a0 = splitted[0].parse::<T0>().unwrap(); let a1 = splitted[1].parse::<T1>().unwrap(); let a2 = splitted[2].parse::<T2>().unwrap(); (a0, a1, a2) } fn read_any_4<T0, T1, T2, T3>(&mut self) -> (T0, T1, T2, T3) where T0: std::str::FromStr, T0::Err: std::fmt::Debug, T1: std::str::FromStr, T1::Err: std::fmt::Debug, T2: std::str::FromStr, T2::Err: std::fmt::Debug, T3: std::str::FromStr, T3::Err: std::fmt::Debug, { let buf = self.read_line(); let splitted = buf.trim().split(' ').collect::<Vec<_>>(); let a0 = splitted[0].parse::<T0>().unwrap(); let a1 = splitted[1].parse::<T1>().unwrap(); let a2 = splitted[2].parse::<T2>().unwrap(); let a3 = splitted[3].parse::<T3>().unwrap(); (a0, a1, a2, a3) } fn read_vec_any<T>(&mut self) -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug, { let buf = self.read_line(); buf.trim().split(' ').map(|s| s.parse::<T>().unwrap()).collect::<Vec<T>>() } fn read_vec_i64(&mut self) -> Vec<i64> { self.read_vec_any::<i64>() } fn read_vec_usize(&mut self) -> Vec<usize> { self.read_vec_any::<usize>() } fn read_vec_str(&mut self) -> Vec<String> { self.read_vec_any::<String>() } fn read_i64_1(&mut self) -> i64 { self.read_any_1::<i64>() } fn read_i64_2(&mut self) -> (i64, i64) { self.read_any_2::<i64, i64>() } fn read_i64_3(&mut self) -> (i64, i64, i64) { self.read_any_3::<i64, i64, i64>() } fn read_i64_4(&mut self) -> (i64, i64, i64, i64) { self.read_any_4::<i64, i64, i64, i64>() } fn read_usize_1(&mut self) -> usize { self.read_any_1::<usize>() } fn read_usize_2(&mut self) -> (usize, usize) { self.read_any_2::<usize, usize>() } fn read_usize_3(&mut self) -> (usize, usize, usize) { self.read_any_3::<usize, usize, usize>() } fn read_usize_4(&mut self) -> (usize, usize, usize, usize) { self.read_any_4::<usize, usize, usize, usize>() } } pub struct ProconReader<R: BufRead> { buf_read: R, } impl<R: BufRead> ProconReader<R> { pub fn new(buf_read: R) -> ProconReader<R> { ProconReader { buf_read } } } impl<R: BufRead> IProconReader for ProconReader<R> { fn read_line(&mut self) -> String { let mut buffer = String::new(); self.buf_read.read_line(&mut buffer).unwrap(); buffer.trim().to_string() } } }