Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- // char buf[1 << 22], *p1 = buf, *p2 = buf;
- // #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
- template <typename T>
- inline void read(T &x)
- {
- x = 0;
- bool flag = false;
- char ch = getchar();
- while (ch < '0' || ch > '9')
- flag = ch == '-' ? true : false, ch = getchar();
- while (ch >= '0' && ch <= '9')
- x = (x << 3) + (x << 1) + (ch & 15), ch = getchar();
- if (flag)
- x = -x;
- }
- template <typename T, typename... Args>
- inline void read(T &t, Args &...args)
- {
- read(t);
- read(args...);
- }
- int main()
- {
- int n, a, b, c, k, X, mp, delta, t;
- int ans1 = 0, ans2 = 0;
- read(n, a, b, c, k, X, mp);
- mp = min(mp / X, k);
- delta = b - a;
- ans1 = k * a;
- while (mp)
- {
- if (ans1 < n)
- {
- // if (mp > 0)
- ans1 += delta;
- }
- else
- {
- t = n - ans1 + a;
- if (t % b)
- (t /= b)++;
- else
- t /= b;
- if (mp > t)
- ans1 -= a, ans2 += c;
- }
- mp--;
- }
- printf("%d %d\n", min(ans1, n), ans2);
- // system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment