1 solutions
-
0
C++ :
#include <iostream> using namespace std; int check(int x, int y) { int cnt = 0; while (x > 0) { int tmp = x % 10; if (tmp == y) { cnt++; } x = x / 10; } return cnt; } int main() { int n, k; cin >> n >> k; int ans = 0; for (int i = 1; i <= n; i++) { ans += check(i, k); } cout << ans << endl; return 0; }
- 1
Information
- ID
- 35
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By