1 solutions
-
0
C++ :
#include<iostream> #include<algorithm> using namespace std; int gcd(int a,int b) { if(b==0) return a; if(a==0) return b; else return gcd(b%a,a); } int main() { int n,m,h,w,ans; while(cin>>n>>m) { if(n==1||m==1) cout<<max(n,m)<<endl; else { cout<<gcd(n-1,m-1)+1<<endl; } } return 0; }
- 1
Information
- ID
- 19607
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- (None)
- # Submissions
- 0
- Accepted
- 0
- Uploaded By