結果

問題 No.2607 Add One Digit
ユーザー vjudge1
提出日時 2025-09-04 22:14:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 563 bytes
コンパイル時間 2,215 ms
コンパイル使用メモリ 203,564 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-04 22:14:45
合計ジャッジ時間 3,409 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long long N;
    if (!(cin >> N)) return 0;
    string s = to_string(N);
    int L = (int)s.size();

    set<string> st;
    for (int pos = 0; pos <= L; ++pos) {
        for (int d = 0; d <= 9; ++d) {
            if (pos == 0 && d == 0) continue; // khng cho s? m?i b?t ??u b?ng 0
            string t = s.substr(0, pos) + char('0' + d) + s.substr(pos);
            st.insert(t);
        }
    }
    cout << st.size() << '\n';
    return 0;
}
0