以下の内容はhttps://blog.hamayanhamayan.com/entry/2019/08/07/204306より取得しました。


Uneven Numbers [AtCoder Beginner Contest 136 B]

https://atcoder.jp/contests/abc136/tasks/abc136_b

解説

https://atcoder.jp/contests/abc136/submissions/6734407

N以下の正の整数は全探索可能。
桁数が奇数であるかは、色々判定方法があるが、[1,9]か[100,999]か[10000,99999]のどれかに入っているかを判定した。

int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;

    int ans = 0;
    rep(i, 1, N + 1) {
        if (1 <= i and i <= 9) ans++;
        else if (100 <= i and i <= 999) ans++;
        else if (10000 <= i and i <= 99999) ans++;
    }
    cout << ans << endl;
}



以上の内容はhttps://blog.hamayanhamayan.com/entry/2019/08/07/204306より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14