1 solutions

  • 0
    @ 2025-11-27 11:55:05

    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

    Information

    ID
    47
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By