What is the approach to this problem?

Pages: 12
> 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.
Question 4 of May Long Challenge ADA ROOKS 2, what is the approach.
@rahulrawat09, I have a linear solution based on an analysis of the problem.
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");
    }
}

so the observation is, if anyone receives a, b and if a>2b then he wins. fantastic!
>
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