SHARE
TWEET

Untitled

a guest Nov 9th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int A, B;
  8.     cin >> A >> B;
  9.  
  10.     if (B * 9 < A)
  11.     {
  12.         cout << "-1";
  13.         return 0;
  14.     }
  15.  
  16.     int min_number = 0, max_number = 0;
  17.     for (int i = 0; i < B; i++)
  18.     {
  19.         int tmp;
  20.         if (A >= 9)
  21.             tmp = 9;
  22.         else
  23.             tmp = A;
  24.  
  25.         A -= tmp;
  26.  
  27.         max_number = max_number * 10 + tmp;
  28.         min_number = tmp * pow(10, i) + min_number;
  29.     }
  30.  
  31.     cout << max_number - min_number;
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top