fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a, b, temp = 0;
  6. bool need = 1;
  7. cin >> a >> b;
  8. while (need) {
  9. if (a >= b) {
  10. temp = temp + a / b;
  11. a = a%b;
  12. }
  13. else
  14. {
  15. temp = temp + b / a;
  16. b = b%a;
  17. }
  18. if (a == 0 || b == 0) {
  19. need = 0;
  20. }
  21. }
  22. cout << temp;
  23. return 0;
  24. }
Success #stdin #stdout 0s 4488KB
stdin
12 4
stdout
3