結果

問題 No.3157 Nabeatsu
ユーザー VvyLw
提出日時 2025-05-29 12:43:16
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 707 bytes
コンパイル時間 2,914 ms
コンパイル使用メモリ 159,588 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-05-29 12:43:21
合計ジャッジ時間 4,194 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    auto n = readln.chomp.dup;
    const len = n.length;
    int id = -1;
    foreach(i, c; n) {
        if(c == '3') {
            id = cast(int)i;
            break;
        }
    }
    if(id == -1) {
        int p = 0;
        foreach(c; n) {
            const m = c - '0';
            p += m;
        }
        const d = ((((n[$ - 1] - '0') - (p % 3 == 0)) + 10) % 10) + '0';
        writeln(n[0..$ - 1] ~ d);
        return;
    }
    const s = n[0..id] ~ "2" ~ "9".replicate(len - id - 1);
    int p = 0;
    foreach(c; s) {
        const m = c - '0';
        p += m;
    }
    const d = ((((s[$ - 1] - '0') - (p % 3 == 0)) + 10) % 10) + '0';
    writeln(s[0..$ - 1] ~ d);
}
0