Submission #7743815


Source Code Expand

Copy
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();

        long c = a(a, b);
        int res = 1;
        for(long i=2; i*i <= c; i++) {
            boolean d = false;
            while(c % i == 0) {
                c /= i;
                d = true;
            }
            if(d) res++;
        }
        if(c > 1) res ++;
        System.out.println(res);
    }

    public static long a(long a, long b) {
        if(a==b) return a;
        if(b > a) {
            return a(b, a);
        }
        if(a % b == 0) {
            return b;
        }
        return a(b, a%b);
    }
}

Submission Info

Submission Time
Task D - Disjoint Set of Common Divisors
User yehara
Language Java8 (OpenJDK 1.8.0)
Score 400
Code Size 765 Byte
Status AC
Exec Time 110 ms
Memory 23636 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 110 ms 22228 KB
sample_02 AC 96 ms 20564 KB
sample_03 AC 93 ms 18900 KB
testcase_01 AC 96 ms 18900 KB
testcase_02 AC 95 ms 20688 KB
testcase_03 AC 101 ms 18640 KB
testcase_04 AC 97 ms 21332 KB
testcase_05 AC 93 ms 20816 KB
testcase_06 AC 98 ms 19668 KB
testcase_07 AC 94 ms 19796 KB
testcase_08 AC 95 ms 18640 KB
testcase_09 AC 94 ms 19284 KB
testcase_10 AC 93 ms 18640 KB
testcase_11 AC 94 ms 21076 KB
testcase_12 AC 94 ms 21460 KB
testcase_13 AC 96 ms 21844 KB
testcase_14 AC 96 ms 23636 KB
testcase_15 AC 94 ms 20564 KB
testcase_16 AC 95 ms 21716 KB
testcase_17 AC 94 ms 21588 KB
testcase_18 AC 93 ms 19924 KB
testcase_19 AC 92 ms 20692 KB
testcase_20 AC 97 ms 20692 KB
testcase_21 AC 96 ms 21844 KB
testcase_22 AC 99 ms 18128 KB
testcase_23 AC 107 ms 21716 KB