What is the approach to this problem?

Pages: 12
May 12, 2019 at 1:38pm
> Did you solved this problem? @salem
Of course not, codechef problems are not interesting to me.
Even if I did, I would be in no mood to just hand all the goodness over to all the wanabies.
May 12, 2019 at 5:22pm
Question 4 of May Long Challenge ADA ROOKS 2, what is the approach.
May 12, 2019 at 7:06pm
@rahulrawat09, I have a linear solution based on an analysis of the problem.
May 13, 2019 at 5:11pm
Now that the contest is over, here's my solution.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

inline bool f(long& a, long b) {
    if (a % b == 0 || a / b > 1) return false;
    a -= b;
    return true;
}

int main() {
    int t;
    std::cin >> t;
    while (t--) {
        long n, m;
        std::cin >> n >> m;
        bool ari = true;
        while (n <= m ? f(m, n) : f(n, m))
            ari = !ari;
        std::cout << (ari ? "Ari\n" : "Rich\n");
    }
}

May 13, 2019 at 10:02pm
so the observation is, if anyone receives a, b and if a>2b then he wins. fantastic!
May 14, 2019 at 10:09am
>
Question 4 of May Long Challenge ADA ROOKS 2, what is the approach

here is one: https://discuss.codechef.com/t/unofficial-editorial-for-adarooks2-may-2019-long-challenge/25572
Topic archived. No new replies allowed.
Pages: 12