题解 | #[NOIP2013]记数问题#

[NOIP2013]记数问题

https://www.nowcoder.com/practice/28b2d9f2bf2c48de94a1297ed90e1732

#include <stdio.h>

int main() {
    int n, x, cnt = 0;
    while (scanf("%d %d", &n, &x) != EOF) {
        int tmp;
        for (int i = 1; i <= n; i++) {
            tmp = i;
            while (tmp) {
                if (tmp % 10 == x) {
                    cnt++;
                }
                tmp /= 10;
            }
        }

        printf("%d\n", cnt);
    }
    return 0;
}
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务