Advertisement
Dang_Quan_10_Tin

BAI2 HSGHN L12 V1 2019-2020

Dec 20th, 2021
1,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #define task "BAI2"
  2.  
  3. #include <iostream>
  4. #include <cstdio>
  5. #include <cmath>
  6.  
  7. using namespace std;
  8.  
  9. using ll = long long;
  10.  
  11. int a, b, k;
  12.  
  13. void Read()
  14. {
  15.     cin >> a >> b >> k;
  16. }
  17.  
  18. void Solve()
  19. {
  20.     if (k == 10)
  21.         cout << 1;
  22.     else
  23.     {
  24.         ll tmp = 10;
  25.         for (int i = 1;; ++i, tmp *= 10)
  26.         {
  27.             if ((a * tmp * 10 + b) % (k - 10) == 0)
  28.                 if ((int)log10((a * tmp * 10 + b) / (k - 10)) + 1 == i)
  29.                 {
  30.                     cout << (a * tmp * 10 + b) / (k - 10);
  31.                     return;
  32.                 }
  33.         }
  34.     }
  35. }
  36.  
  37. int32_t main()
  38. {
  39.     ios::sync_with_stdio(0);
  40.     cin.tie(0);
  41.     cout.tie(0);
  42.     if (fopen(task ".INP", "r"))
  43.     {
  44.         freopen(task ".INP", "r", stdin);
  45.         freopen(task ".OUT", "w", stdout);
  46.     }
  47.  
  48.     Read();
  49.     Solve();
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement