Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- ll n, k, a, b, c, d;
- bool check(ll pos, int guy) {
- ll sum1 = 0, sum2 = 0;
- int state = guy;
- for (ll i = pos; i <= n; i += k) {
- if (!state) {
- if (i >= a && i <= b)
- ++sum2;
- else
- ++sum1;
- }
- else {
- if (i >= c && i <= d)
- ++sum1;
- else
- ++sum2;
- }
- state ^= 1;
- }
- // cout << sum1 << " " << sum2 << endl;
- return sum1 == sum2;
- }
- int main() {
- //0 - d, 1 - m
- cin >> n >> k >> a >> b >> c >> d;
- for (int i = 1; i <= k; ++i) {
- if (check(i, 1)) {
- cout << i << '\n' << "Mitya";
- return 0;
- }
- if (check(i, 0)) {
- cout << i << '\n' << "Dima";
- return 0;
- }
- }
- cout << -1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement