Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- #include <math.h>
- #include <vector>
- #include <fstream>
- using namespace std;
- int getSize(int x) {
- int l = 0;
- while (x > 0) {
- l++;
- x /= 10;
- }
- return l;
- }
- int main()
- {
- int N, x;
- cin >> N >> x;
- int l = getSize(x);
- int ans = 0;
- cout << "l = " << l << endl;
- cout << "10^ = " << (int) pow(10, l) << endl;
- for (int i = 1; i < N; ++i) {
- int t = pow(10, l);
- if (t % 10 != 0) t++;
- if ( ( i % t) == x ) {
- cout << i << " ";
- ans++;
- }
- }
- cout << endl << "Ans program = " << ans << endl;
- int myAns = 0;
- myAns = N/(pow(10,l));
- if ( N % ( (int) pow(10, l) ) < x) {
- myAns++;
- }
- cout << "My ans = " << myAns << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement