Common Prime
Practice
3 (4 votes)
Algorithms
Easy
String manipulation
Problem
87% Success 16140 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
15 votes
Tags:
AlgorithmsString ManipulationString manipulation
Points:20
42 votes
Tags:
Data StructuresEasySortingString Manipulationapproved
Points:20
8 votes
Tags:
StringBrute ForceAlgorithmsString SearchingBinary SearchString Algorithms
Editorial