Submission #7744066


Source Code Expand

Copy
import math


def gcd(a, b):
    a, b = max(a, b), min(a, b)
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    rt = int(math.sqrt(g))
    ans = set([1])
    for x in range(2, rt+1):
        if g % x == 0:
            ans.add(x)
            while g % x == 0:
                g //= x
    if g != 1:
        ans.add(g)
    print(len(ans))


if __name__ == "__main__":
    main()

Submission Info

Submission Time
Task D - Disjoint Set of Common Divisors
User blcn
Language PyPy3 (2.4.0)
Score 400
Code Size 483 Byte
Status AC
Exec Time 182 ms
Memory 38512 KB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 26
AC × 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18, testcase_19, testcase_20, testcase_21, testcase_22, testcase_23
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 AC 166 ms 38256 KB
sample_02 AC 166 ms 38256 KB
sample_03 AC 170 ms 38256 KB
testcase_01 AC 165 ms 38256 KB
testcase_02 AC 170 ms 38256 KB
testcase_03 AC 182 ms 38512 KB
testcase_04 AC 166 ms 38384 KB
testcase_05 AC 169 ms 38384 KB
testcase_06 AC 168 ms 38384 KB
testcase_07 AC 165 ms 38384 KB
testcase_08 AC 165 ms 38384 KB
testcase_09 AC 167 ms 38256 KB
testcase_10 AC 169 ms 38384 KB
testcase_11 AC 175 ms 38384 KB
testcase_12 AC 178 ms 38384 KB
testcase_13 AC 167 ms 38256 KB
testcase_14 AC 181 ms 38384 KB
testcase_15 AC 167 ms 38384 KB
testcase_16 AC 173 ms 38384 KB
testcase_17 AC 178 ms 38512 KB
testcase_18 AC 178 ms 38512 KB
testcase_19 AC 164 ms 38384 KB
testcase_20 AC 166 ms 38384 KB
testcase_21 AC 166 ms 38384 KB
testcase_22 AC 168 ms 38384 KB
testcase_23 AC 176 ms 38384 KB