题解

FJP 2022-12-30 16:30:41 7 返回题目

#include <bits/stdc++.h> using namespace std;

int n, sum;

int check(int n) { int ans = 0; while (n) { ans += (n % 10 == 1); n /= 10; } return ans; }

signed main() { cin >> n; for (int i = 1; i <= n; ++i) sum += check(i); cout << sum; return 0; }

{{ vote && vote.total.up }}