結果
| 問題 |
No.2784 繰り上がりなし十進和
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-06-20 03:25:01 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 398 ms / 2,000 ms |
| コード長 | 1,090 bytes |
| コンパイル時間 | 28,598 ms |
| コンパイル使用メモリ | 402,432 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-20 03:25:37 |
| 合計ジャッジ時間 | 19,572 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
コンパイルメッセージ
warning: variable `A` should have a snake case name
--> src/main.rs:8:13
|
8 | let mut A = Vec::new();
| ^ help: convert the identifier to snake case: `a`
|
= note: `#[warn(non_snake_case)]` on by default
warning: variable `U` should have a snake case name
--> src/main.rs:14:9
|
14 | let U: Vec<i32> = (0..6).map(|i| 10i32.pow(i)).collect();
| ^ help: convert the identifier to snake case (notice the capitalization): `u`
warning: variable `U` should have a snake case name
--> src/main.rs:17:29
|
17 | fn calc(x: i32, y: i32, U: &Vec<i32>) -> i32 {
| ^ help: convert the identifier to snake case (notice the capitalization): `u`
warning: variable `ANS` should have a snake case name
--> src/main.rs:18:17
|
18 | let mut ANS = 0;
| ^^^ help: convert the identifier to snake case: `ans`
warning: variable `DP` should have a snake case name
--> src/main.rs:26:13
|
26 | let mut DP = vec![0; 1_000_000];
| ^^ help: convert the identifier to snake case: `dp`
warning: variable `Q` should have a snake case name
--> src/main.rs:28:13
|
28 | let mut Q = VecDeque::new();
| ^ help: convert the identifier to snake case: `q`
ソースコード
use std::collections::VecDeque;
use std::io::{self, BufRead};
fn main() {
// Read input
let stdin = io::stdin();
let mut iterator = stdin.lock().lines();
let mut A = Vec::new();
for _ in 0..6 {
A.push(iterator.next().unwrap().unwrap().parse::<i32>().unwrap());
}
// Generate U array
let U: Vec<i32> = (0..6).map(|i| 10i32.pow(i)).collect();
// Function to calculate the result
fn calc(x: i32, y: i32, U: &Vec<i32>) -> i32 {
let mut ANS = 0;
for &i in U.iter() {
ANS += ((x / i + y / i) % 10) * i;
}
ANS
}
// DP array
let mut DP = vec![0; 1_000_000];
DP[0] = 1;
let mut Q = VecDeque::new();
Q.push_back(0);
// Process the queue
while let Some(x) = Q.pop_front() {
for &a in A.iter() {
let to = calc(a, x, &U);
if DP[to as usize] == 0 {
DP[to as usize] = 1;
Q.push_back(to);
}
}
}
// Sum the DP array
let result: i32 = DP.iter().sum();
println!("{}", result);
}
titia