結果

問題 No.2086 A+B問題
コンテスト
ユーザー hayatroid
提出日時 2022-10-01 20:23:09
言語 Rust
(1.99.0 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WA  
実行時間 -
コード長 681 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 10,013 ms
コンパイル使用メモリ 192,724 KB
実行使用メモリ 9,828 KB
最終ジャッジ日時 2026-10-06 23:46:00
合計ジャッジ時間 4,575 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 8
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: value assigned to `carry` is never read
  --> src/main.rs:17:9
   |
17 |         carry = 0;
   |         ^^^^^^^^^ this value is reassigned later and never used
...
25 |         carry = tmp / 10;
   |         ---------------- `carry` is overwritten here before the previous value is read
   |
   = note: `#[warn(unused_assignments)]` (part of `#[warn(unused)]`) on by default

ソースコード

diff #
raw source code

fn read() -> Vec<u8> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().bytes().rev().map(|x| x - b'0').collect::<Vec<_>>()
}

fn main() {
    let a = read();
    let b = read();
    let mut ans = String::new();
    let mut carry = 0;
    for i in 0.. {
        if i >= a.len() && i >= b.len() && carry == 0 {
            break;
        }
        let mut tmp = carry;
        carry = 0;
        if i < a.len() {
            tmp += a[i];
        }
        if i < b.len() {
            tmp += b[i];
        }
        tmp -= tmp / 10 * 10;
        carry = tmp / 10;
        ans = format!("{}{}", tmp, ans);
    }
    println!("{}", ans);
}
0