Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- int cmmdc(int a, int b){
- if(a==0)
- return b;
- else
- if(b==0)
- return a;
- else{
- while(a!=b)
- if(a > b)
- a = a - b;
- else
- b = b - a;
- return b;
- }
- }
- int cmmmc(int a, int b){
- return (a*b)/cmmdc(a,b);
- }
- int main(){
- ifstream f1("atestat.in");
- ofstream f2("atestat.out");
- int x,y,n,m1=0,m2=0,ir=0;
- f1>>n;
- while(f1>>x>>y){
- if(cmmdc(x,y)==1)
- ir++;
- if(m1!=0)
- m2=y;
- if(m1==0)
- m1=y;
- if(m1 != 0 & m2 != 0)
- m1=cmmmc(m1,m2);
- }
- f2<<ir<<" "<<m1;
- f2.close();
- f1.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement