Submission #73049304


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a),E##i=(b);i<=E##i;i++)
#define REV(i,a,b) for(int i=(a),E##i=(b);i>=E##i;i--)
#define CLOSE_TIE ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define psbk push_back
#define endl '\n'
template <typename T>
void _outval(string s,int p,const T &t) {cout<<s.substr(p,s.length()-p)<<'='<<t<<endl; }
template <typename T, typename... Args>
void _outval(string s,int p,const T &t,const Args &...rest){
    string n=""; while(s[p]!=',') n+=s[p++]; cout<<n<<'='<<t<<", ";
    _outval(s,p+1,rest...);
}
#define outval(...) _outval(#__VA_ARGS__,0,__VA_ARGS__)
#define outarr(a,be,ed)\
{cout<<(#a)<<": ";\
FOR(iiii,be,ed)cout<<'['<<iiii<<"]="<<a[iiii]<<", "; cout<<endl;}
int n,k,ans;
int main(){
//    freopen("in.txt","r",stdin);
    CLOSE_TIE
    cin>>n>>k;
    FOR(i,1,n){
        int t=i,s=0;
        while(t) s+=t%10,t/=10;
        if(s==k) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task B - Digit Sum
User FYCCCTA2011
Language C++23 (GCC 15.2.0)
Score 200
Code Size 1019 Byte
Status AC
Exec Time 2 ms
Memory 3600 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 3544 KiB
random_02.txt AC 1 ms 3592 KiB
random_03.txt AC 1 ms 3544 KiB
random_04.txt AC 1 ms 3600 KiB
random_05.txt AC 1 ms 3528 KiB
random_06.txt AC 1 ms 3520 KiB
random_07.txt AC 1 ms 3568 KiB
random_08.txt AC 1 ms 3460 KiB
random_09.txt AC 1 ms 3536 KiB
sample_01.txt AC 1 ms 3528 KiB
sample_02.txt AC 1 ms 3484 KiB
sample_03.txt AC 2 ms 3432 KiB