Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long long n, k, a, b, c, d;
- bool check(long long pos, int ind) {
- long long s1 = 0, s2 = 0;
- int t = ind;
- for (long long i = pos; i <= n; i += k) {
- if (!t) {
- if (i >= a && i <= b)
- ++s2;
- else
- ++s1;
- }
- else {
- if (i >= c && i <= d)
- ++s1;
- else
- ++s2;
- }
- if (t)
- t = 0;
- else
- t = 1;
- }
- return s1 - s2 == 0;
- }
- int main() {
- cin >> n >> k >> a >> b >> c >> d;
- for (int i = 1; i <= k; ++i) {
- if (check(i, 1)) {
- cout << i << endl << "Mitya";
- return 0;
- }
- if (check(i, 0)) {
- cout << i << endl << "Dima";
- return 0;
- }
- }
- cout << -1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement