Advertisement
IISergeyII

Untitled

May 24th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 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 ans = 0;
  27.  
  28.     cout << "l = " << l << endl;
  29.     cout << "10^ = " << (int) pow(10, l) << endl;
  30.     for (int i = 1; i < N; ++i) {
  31.         int t = pow(10, l);
  32.         if (t % 10 != 0) t++;
  33.         if ( ( i % t) == x ) {
  34.             cout << i << " ";
  35.             ans++;
  36.         }
  37.     }
  38.  
  39.     cout << endl << "Ans program = " << ans << endl;
  40.  
  41.     int myAns = 0;
  42.     myAns = N/(pow(10,l));
  43.     if ( N % ( (int) pow(10, l) ) < x)  {
  44.         myAns++;
  45.     }
  46.     cout << "My ans = " << myAns << endl;
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement