Please enter your email address or userHandle.
Given three integers N, x and y, a number A is formed by repeating N x times and another number B is formed by repeating N y times. You need to find the GCD(A,B).
Input: N = 1, x = 1, y = 1
Explanation: A = 1, B = 1, GCD(1, 1) = 1
Input: N = 2, x = 2, y = 2
Explanation: A = 22, B = 222, GCD(22, 222) = 2
You don't need to read or print anything. Your task is to complete the function FindGcd() which takes N, x and y as input parameter and returns GCD(A, B) in string form.
Expected Time Complexity: O(Log10(N) * GCD(x, y))
Expected Space Complexity: O(Log10(N) * GCD(x, y))
1 <= x, y <= 100000
1 <= N <= 1018
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.