Advertisement
IISergeyII

Untitled

May 24th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <math.h>
  5. #include <vector>
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10. int getSize(int x) {
  11.     int l = 0;
  12.     while (x > 0) {
  13.         l++;
  14.         x /= 10;
  15.     }
  16.  
  17.     return l;
  18. }
  19.  
  20. int main()
  21. {
  22.     int N, x;
  23.     cin >> N >> x;
  24.  
  25.     int l = getSize(x);
  26.     int p = pow(10, l);
  27.     if (p % 10 != 0) p++;
  28.  
  29.     int ans = 0;
  30.  
  31.     //cout << "l = " << l << endl;
  32.     //cout << "10^ = " << (int) pow(10, l) << endl;
  33.     for (int i = 1; i < N; ++i) {
  34.         if ( ( i % p) == x ) {
  35.             cout << i << " ";
  36.             ans++;
  37.         }
  38.     }
  39.  
  40.     cout << endl << "Ans program = " << ans << endl;
  41.  
  42.     int myAns = 0;
  43.     myAns = N/p;
  44.     if ( N % p > x)  {
  45.         myAns++;
  46.     }
  47.     cout << "My ans = " << myAns << endl;
  48.  
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement