fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int gcd(int a, int b){
  5. return b == 0 ? a : gcd(b, a % b);
  6. }
  7.  
  8. int main() {
  9. int n, m;
  10. cin >> n >> m;
  11. cout << gcd(n - 1, m - 1) + 1 << endl;
  12. return 0;
  13. }
Success #stdin #stdout 0s 15232KB
stdin
3 2
stdout
2