Skip to content

Commit

Permalink
past202303-open b
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Nov 22, 2023
1 parent 8dfd630 commit 4fa49a1
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions 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::<String>());
}

0 comments on commit 4fa49a1

Please sign in to comment.