Submission #75358775
Source Code Expand
Copy
#include <stdio.h>/*桁DP……っぽいけど、面倒だし制約が小さいので全探索*/int ketawa(int n) {int res = 0;while (n > 0) {res += n % 10;n /= 10;}return res;}int main(void) {int N, K;int i, ans = 0;if (scanf("%d%d", &N, &K) != 2) return 1;for (i = 1; i <= N; i++) {ans += ketawa(i) == K;}printf("%d\n", ans);return 0;}
#include <stdio.h>
/*
桁DP……っぽいけど、面倒だし制約が小さいので全探索
*/
int ketawa(int n) {
int res = 0;
while (n > 0) {
res += n % 10;
n /= 10;
}
return res;
}
int main(void) {
int N, K;
int i, ans = 0;
if (scanf("%d%d", &N, &K) != 2) return 1;
for (i = 1; i <= N; i++) {
ans += ketawa(i) == K;
}
printf("%d\n", ans);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Digit Sum |
| User | mikecat |
| Language | C23 (GCC 14.2.0) |
| Score | 200 |
| Code Size | 404 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 1720 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 | 1 ms | 1720 KiB |
| random_02.txt | AC | 1 ms | 1620 KiB |
| random_03.txt | AC | 0 ms | 1620 KiB |
| random_04.txt | AC | 1 ms | 1692 KiB |
| random_05.txt | AC | 0 ms | 1612 KiB |
| random_06.txt | AC | 1 ms | 1668 KiB |
| random_07.txt | AC | 1 ms | 1640 KiB |
| random_08.txt | AC | 1 ms | 1632 KiB |
| random_09.txt | AC | 1 ms | 1620 KiB |
| sample_01.txt | AC | 0 ms | 1640 KiB |
| sample_02.txt | AC | 0 ms | 1632 KiB |
| sample_03.txt | AC | 1 ms | 1632 KiB |