1 条题解

  • 0
    @ 2025-11-3 0:21:51

    C++ :

    #include <algorithm>
    #include <cstdio>
    using namespace std;
    int n, ans;
    int main() {
    	scanf("%d", &n);
    	for (int i = 1; i <= n; i++) {
    	int v = i % 10, t = i / 10, chk = 1;
    	while (t) {
    		if (t % 10 != v) chk = 0;
    			t /= 10;
    		}
    		ans += chk;
    	}
    	printf("%d\n", ans);
    	return 0;
    }
    
    • 1

    信息

    ID
    5638
    时间
    1000ms
    内存
    128MiB
    难度
    2
    标签
    递交数
    7
    已通过
    4
    上传者