CBOJ Fall Challenge '24 P4 - Factor Graph
A factor graph is defined such that for a pair of nodes \((u, v)\), there exists an edge between them if and only if \(u\) is a factor of \(v\) or \(v\) is a factor of \(u\).
Given an integer \(N\), determine whether the factor graph formed by the factors of \(N\) (including \(1\) and \(N\)) is a complete graph . A complete graph is defined as a graph in which every pair of distinct nodes is connected by an edge.
Constraints
\(2 \le N \le 10^{12}\)
Input Specification
The first line of input contains one integer, \(N\).
It is possible for these values to exceed the limits of a 32-bit integer.
It is advised to use 64-bit integers instead, meaning that Java users should use long
, and C++ users should use long long
.
Output Specification
Output YES
if it is a complete graph, otherwise output NO
.
Sample Input 1
5
Sample Output 1
YES
Sample Input 2
6
Sample Output 2
NO
Graph of Sample 2
This is the factor graph of 6:
Comments