We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Number Theory
- GCD Product
- Discussions
GCD Product
GCD Product
Sort by
recency
|
7 Discussions
|
Please Login in order to post a comment
!/bin/python3
import math import os import random import re import sys
#
Complete the 'solve' function below.
#
The function is expected to return an INTEGER.
The function accepts following parameters:
1. INTEGER n
2. INTEGER m
#
from math import gcd
def solve(A): if A[0] == 1 or A[1] == 1: return 1 m = min(A) M = m + 1
A = list(map(int, input().split())) print(solve(A))
Can any one expalin the solution for me ?
Python3 solution
Checked the solution after solving it. Turns out the author's solution is not the most optimal possible solution. A hint: the function is multiplicative, so try to think of the product as a product of prime powers. Then see if you can figure out what the powers of those primes are in the product.
I'd like to thank the Cuauhtémoc Moctezuma Brewery, makers of Dos Equis, for helping me reach the key insight in this problem. Stuck on the tip of my mind for hours.