提出 #73071908


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull=unsigned long long;
const int INF = 1e9;
const long long INFLL = (long long)1e18;
const double PI = acos(-1);
//cout << fixed << setprecision(15) << ans << '\n';

int main()
{
  int n,k;cin>>n>>k;
  int ans=0;
  for(int i=1;i<=n;i++)
  {
    if(i<10)
    {
      if(i==k)ans++;
      continue;
    }
    int m=i,sum=0;
    while(m)
    {
      sum+=m%10;
      m=(m-m%10)/10;
    }
    
    if(sum==k)
    {
      ans++;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

提出情報

提出日時
問題 B - Digit Sum
ユーザ maou1
言語 C++23 (GCC 15.2.0)
得点 200
コード長 603 Byte
結果 AC
実行時間 2 ms
メモリ 3628 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 3540 KiB
random_02.txt AC 2 ms 3552 KiB
random_03.txt AC 1 ms 3436 KiB
random_04.txt AC 2 ms 3552 KiB
random_05.txt AC 1 ms 3324 KiB
random_06.txt AC 2 ms 3324 KiB
random_07.txt AC 1 ms 3528 KiB
random_08.txt AC 2 ms 3540 KiB
random_09.txt AC 2 ms 3540 KiB
sample_01.txt AC 1 ms 3628 KiB
sample_02.txt AC 1 ms 3316 KiB
sample_03.txt AC 2 ms 3588 KiB