A - Playing with Paper(527A - Playing with Paper)

  1. 527A - Playing with Paper


  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. int main()
  5. { long long a,b;
  6. long long x=0,y=0,z=0,ans=0;
  7. cin>>a>>b;
  8. if(b==1) cout<< a*b;
  9. else {
  10. while(a>0 and b>0){
  11. if(a>b)
  12. { ans= ans+a/b;
  13. a=a%b;}
  14. else if(b>a){
  15. ans+=b/a;
  16. b=b%a;
  17. }
  18. }
  19. }
  20. if(ans>1)
  21. cout<<ans ;
  22. }

Comments

Popular posts from this blog

Codeforce Problem 1703A. YES or YES?

Aptitude test assistant programmer 2018

1041A. Heist solution