Submission #73055894
Source Code Expand
#include <iostream>
using namespace std;
int calculate_digit_sum(int num) {
int sum = 0;
while (num > 0) {
sum += num % 10;
num /= 10;
}
return sum;
}
int main() {
int N, K;
cin >> N >> K;
int count = 0;
for (int i = 1; i <= N; ++i) {
if (calculate_digit_sum(i) == K) {
count++;
}
}
cout << count;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Digit Sum |
| User | xuhanjin |
| Language | C++23 (GCC 15.2.0) |
| Score | 200 |
| Code Size | 418 Byte |
| Status | AC |
| Exec Time | 2 ms |
| Memory | 3620 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| 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 | 3372 KiB |
| random_03.txt | AC | 1 ms | 3620 KiB |
| random_04.txt | AC | 2 ms | 3568 KiB |
| random_05.txt | AC | 1 ms | 3412 KiB |
| random_06.txt | AC | 2 ms | 3432 KiB |
| random_07.txt | AC | 1 ms | 3608 KiB |
| random_08.txt | AC | 2 ms | 3432 KiB |
| random_09.txt | AC | 1 ms | 3524 KiB |
| sample_01.txt | AC | 1 ms | 3396 KiB |
| sample_02.txt | AC | 1 ms | 3488 KiB |
| sample_03.txt | AC | 1 ms | 3368 KiB |