よじろめ覚書

私の理解度重視のソースコードです。

ABC083B - Some Sums

問題:B - Some Sums

#include <iostream>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
    int n, a, b, tmp, sum, ans = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    REP(i, n + 1) {
        tmp = i;
        sum = 0;
        while (tmp >= 1) {
            sum += tmp % 10;
            tmp /= 10;
        }

        if (a <= sum && sum <= b) {
            ans += i;
        }
    }

    cout << ans << "\n";
    return 0;
}