From 267b2db7addc95c5eebb8bfb9ceeb7b953d85732 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Tue, 14 May 2019 11:55:28 +0700 Subject: I has always believed that I'm good at solving math problems Turns out I has been wrong all the time. And I'm not alone. --- codechef/matchs.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 codechef/matchs.c (limited to 'codechef/matchs.c') diff --git a/codechef/matchs.c b/codechef/matchs.c new file mode 100644 index 0000000..7831378 --- /dev/null +++ b/codechef/matchs.c @@ -0,0 +1,23 @@ +#include +#define MAX(x, y) (((n) > (m)) ? (n) : (m)) +#define MIN(x, y) (((n) > (m)) ? (m) : (n)) + +int match(long long x, long long y, int ari) +{ + long long mod = x % y; + return (mod && x - y == mod) ? match(y, mod, !ari) : ari; +} + +int main() +{ + int t; + long long n, m; + + scanf("%d", &t); + while (t--) { + scanf("%lld %lld", &n, &m); + puts(match(MAX(n, m), MIN(n, m), 1) ? "Ari" : "Rich"); + } + + return 0; +} -- cgit 1.4.1