Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- int cmmdc(int a,int b)
- {
- if(a==0&&b==0)
- return -1;
- else
- {
- if(a<b)
- swap(a,b);
- if(b==0)
- return a;
- else
- {
- int r=a%b;
- while (r)
- a=b,b=r,r=a%b;
- return b;
- }
- }
- }
- int main ()
- {
- int n,m;
- ifstream f("tort.in");
- f>>n>>m;
- f.close();
- ofstream g("tort.out");
- int d=cmmdc(n,m);
- g<<(n/d)*(m/d)<<' '<<d;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement