Submission #75002446


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

mt19937_64    rng(chrono::steady_clock::now().time_since_epoch().count());

#define       nline                     "\n"
#define       pb                        push_back
#define       ppb                       pop_back
#define       mp                        make_pair
#define       ff                        first
#define       ss                        second
#define       fall(x, n)                for(int x=0; x<n; x++)
#define       rall(x, n)                for(int x=n-1; x>=0; x--)
#define       frange(x, start, end)     for(int x=start; x<=end; x++)
#define       rrange(x, start, end)     for(int x=start; x>=end; x--)
#define       in(i, v)                  for(auto &i: v) cin >> i;
#define       vi                        vector<int>
#define       ii                        pair<int, int>
#define       sz(x)                     ((int)(x).size())
#define       all(x)                    (x).begin(), (x).end()
#define       mod                       1000000007
#define       INF                       0x1fffffffffffffffLL

typedef       long long                 ll;
typedef       unsigned long long        ull;
typedef       long double               lld;

#ifdef        LOCAL
#include      "debug.h"
#else
#define       debug(x)
#endif

#define       int                       long long

void solve()
{
    int n, m; cin >> n >> m;
    int ans = 0;
    frange(i, 1, n) {
        int sum = 0, di = i;
        while (di > 0) {
            sum += di % 10;
            di /= 10;
        }
        if (sum == m) ans++;
    }
    cout << ans << nline;
}

signed main()
{
#ifdef LOCAL
    freopen("i.txt", "r", stdin); freopen("o.txt", "w", stdout); freopen("e.txt", "w", stderr);
#endif
    auto begin = chrono::high_resolution_clock::now();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    while (t--) solve();
    auto end = chrono::high_resolution_clock::now();
    auto elapsed = chrono::duration_cast<chrono::nanoseconds>(end - begin);
    cerr << fixed << "Time measured <= *_* => " << elapsed.count() * 1e-9 << " seconds.\n";
    return 0;
}

Submission Info

Submission Time
Task D - Digit Sum
User kumaresh_rk
Language C++23 (GCC 15.2.0)
Score 200
Code Size 2201 Byte
Status AC
Exec Time 2 ms
Memory 3972 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 12
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 2 ms 3948 KiB
random_02.txt AC 2 ms 3832 KiB
random_03.txt AC 1 ms 3864 KiB
random_04.txt AC 2 ms 3832 KiB
random_05.txt AC 1 ms 3908 KiB
random_06.txt AC 2 ms 3844 KiB
random_07.txt AC 1 ms 3972 KiB
random_08.txt AC 2 ms 3920 KiB
random_09.txt AC 2 ms 3836 KiB
sample_01.txt AC 1 ms 3916 KiB
sample_02.txt AC 1 ms 3920 KiB
sample_03.txt AC 2 ms 3844 KiB