提出 #73055987


ソースコード 拡げる

#include <algorithm>
//#include <atcoder/all>
//#include <array>
//#include <bitset>
//#include <cmath>
//#include <deque>
#include <iostream>
#include <map>
//#include <numeric>
#include <queue>
//#include <ranges>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define pb push_back
#define fr first
#define sc second
#define sor(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int,int>;
//using pll = pair<ll,ll>;
//using pqdec = priority_queue<int,vector<int>,greater<int>>;
//using pqdecl = priority_queue<ll,vector<ll>,greater<ll>>;
template <typename T>
using graph = vector<vector<T>>;
const ll LLMAX = 9223372*1e10;
const int IMAX = 214*1e7;
/*--------考察--------------------
----------CODING----------------*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    int ans = 0;
    rep(i,n+1){
        int j = i;
        int ret = 0;
        while(j > 0){
            ret += j % 10;
            j /= 10;
        }
        if(ret == k) ans++;
    }
    cout << ans << endl;
}

提出情報

提出日時
問題 B - Digit Sum
ユーザ scotch_at
言語 C++23 (GCC 15.2.0)
得点 200
コード長 1251 Byte
結果 AC
実行時間 2 ms
メモリ 3632 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 12
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
random_01.txt AC 2 ms 3520 KiB
random_02.txt AC 2 ms 3584 KiB
random_03.txt AC 1 ms 3500 KiB
random_04.txt AC 2 ms 3632 KiB
random_05.txt AC 1 ms 3632 KiB
random_06.txt AC 2 ms 3524 KiB
random_07.txt AC 1 ms 3476 KiB
random_08.txt AC 1 ms 3524 KiB
random_09.txt AC 2 ms 3584 KiB
sample_01.txt AC 1 ms 3608 KiB
sample_02.txt AC 1 ms 3544 KiB
sample_03.txt AC 1 ms 3516 KiB