Advertisement
JouJoy

D

Dec 10th, 2021
1,160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include<set>
  3.  
  4. using namespace std;
  5.  
  6. const int N = 1e7 + 10, inF = 1e9;
  7.  
  8. bool mark[N];
  9. int a, b, mod;
  10. set<pair<int, int > > s;
  11.  
  12. int main() {
  13.     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  14.     cin >> a >> b >> mod;
  15.     int p = inF % mod;
  16.     for (int i = 0; i <= min(a, mod - 1); i++) {
  17.         int k = (1LL * p * i) % mod;
  18.         if ((mod - k) % mod > b) {
  19.             cout << 1 << ' ';
  20.             int x = i, d = 0;
  21.             while (x)
  22.                 x /= 10, d++;
  23.             for (int j = 0; j < 9 - d; j++)
  24.                 cout << 0;
  25.             return cout << i, 0;
  26.         }
  27.     }
  28.     cout << 2, 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement