fork download
  1. #include <iostream>
  2. #include <numeric>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(NULL);
  9.  
  10. long long a, b;
  11. if (cin >> a >> b) {
  12. long long g = std::gcd(a, b);
  13.  
  14. if (g == 1) {
  15. cout << -1 << "\n";
  16. return 0;
  17. }
  18.  
  19. long long smallest_factor = g;
  20. for (long long i = 2; i * i <= g; ++i) {
  21. if (g % i == 0) {
  22. smallest_factor = i;
  23. break;
  24. }
  25. }
  26.  
  27. cout << g / smallest_factor << "\n";
  28. }
  29.  
  30. return 0;
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12:28: error: ‘gcd’ is not a member of ‘std’
         long long g = std::gcd(a, b);
                            ^~~
stdout
Standard output is empty