Advertisement
a53

Covorul

a53
Dec 23rd, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,m;
  7. cin>>n>>m;
  8. if(m>n)
  9. swap(n,m);
  10. cout<<m<<' ';
  11. int sol=0;
  12. while(m)
  13. {
  14. sol+=n/m;
  15. if(n%m==0)
  16. break;
  17. n%=m;
  18. swap(n,m);
  19. }
  20. cout<<sol;
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement