From 4fa49a119e55dcfcfd2e444bd6f8e994c65db0c6 Mon Sep 17 00:00:00 2001 From: bouzuya Date: Wed, 22 Nov 2023 22:04:47 +0900 Subject: [PATCH] past202303-open b --- .../contests/past202303-open/src/bin/b.rs | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/cargo-atcoder-1.70.0/contests/past202303-open/src/bin/b.rs b/cargo-atcoder-1.70.0/contests/past202303-open/src/bin/b.rs index 2a9506c8..6c766fac 100644 --- a/cargo-atcoder-1.70.0/contests/past202303-open/src/bin/b.rs +++ b/cargo-atcoder-1.70.0/contests/past202303-open/src/bin/b.rs @@ -1,10 +1,32 @@ -use proconio::{input, marker::Usize1}; +use proconio::{input, marker::Chars}; fn main() { input! { - n: usize, - a: [Usize1; n], + d: usize, + mut a: Chars, + mut b: Chars, }; - let ans = n - a.len(); - println!("{}", ans); + + let len = a.len().max(b.len()); + a.reverse(); + b.reverse(); + let mut c = 0; + let mut ans = vec![]; + for i in 0..len { + if i == d { + ans.push('.'); + continue; + } + let x = (*a.get(i).unwrap_or(&'0') as u8 - b'0') as usize; + let y = (*b.get(i).unwrap_or(&'0') as u8 - b'0') as usize; + ans.push((((x + y + c) % 10) as u8 + b'0') as char); + c = (x + y + c) / 10; + } + if c != 0 { + ans.push((c as u8 + b'0') as char); + } + + ans.reverse(); + + println!("{}", ans.into_iter().collect::()); }