Astral_Rider

Untitled

Feb 16th, 2023 (edited)
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. // char buf[1 << 22], *p1 = buf, *p2 = buf;
  5. // #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
  6. template <typename T>
  7. inline void read(T &x)
  8. {
  9.     x = 0;
  10.     bool flag = false;
  11.     char ch = getchar();
  12.     while (ch < '0' || ch > '9')
  13.         flag = ch == '-' ? true : false, ch = getchar();
  14.     while (ch >= '0' && ch <= '9')
  15.         x = (x << 3) + (x << 1) + (ch & 15), ch = getchar();
  16.     if (flag)
  17.         x = -x;
  18. }
  19. template <typename T, typename... Args>
  20. inline void read(T &t, Args &...args)
  21. {
  22.     read(t);
  23.     read(args...);
  24. }
  25.  
  26. int main()
  27. {
  28.     int n, a, b, c, k, X, mp, delta, t;
  29.     int ans1 = 0, ans2 = 0;
  30.     read(n, a, b, c, k, X, mp);
  31.  
  32.     mp = min(mp / X, k);
  33.     delta = b - a;
  34.  
  35.     ans1 = k * a;
  36.     while (mp)
  37.     {
  38.         if (ans1 < n)
  39.         {
  40.             // if (mp > 0)
  41.                 ans1 += delta;
  42.         }
  43.         else
  44.         {
  45.             t = n - ans1 + a;
  46.             if (t % b)
  47.                 (t /= b)++;
  48.             else
  49.                 t /= b;
  50.  
  51.             if (mp > t)
  52.                 ans1 -= a, ans2 += c;
  53.         }
  54.  
  55.         mp--;
  56.     }
  57.  
  58.     printf("%d %d\n", min(ans1, n), ans2);
  59.  
  60.     // system("pause");
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment