Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <bits/stdc++.h>
using namespace std;
long long q, sqrtq;
vector <int> fact;
int main() {
scanf("%lld", &q);
sqrtq = sqrt(q) + 1;
for(int i = 2; i <= sqrtq; ++i)
while(q % i == 0)
fact.push_back(i), q /= i;
if(q > 1)
fact.push_back(q);
if(fact.size() <= 1)
puts("1\n0");
else if(fact.size() == 2)
puts("2");
else {
puts("1");
printf("%lld\n", 1ll * fact[0] * fact[1]);
}
return 0;
}
Copy The Code &
Try With Live Editor
Input
6
Output
2
Demonstration
Codeforcess Solution Win or Freeze, C. Win or Freeze C,C++, Java, Js and Python ,Win or Freeze,C. Win or Freeze