Common Prime
Practice
3 (4 votes)
Algorithms
Easy
String manipulation
Problem
87% Success 16135 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Given two numbers \(A\) and \(B\), find the smallest prime number that divides both of them or state that such number does not exist.
Input
First and only line of input contains two integers \(A\) and \(B\).
Output
Print the smallest common prime divisor of \(A\) and \(B\) or \(-1\) if it does not exist.
Constraints
\(1 \le A,B \le 10^{15}\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
61 votes
Tags:
EasyImplementationString Manipulation
Points:20
13 votes
Tags:
AlgorithmsString ManipulationTwo pointer
Points:20
8 votes
Tags:
Easy
Editorial