fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a, b, temp=0;
  6. cin >> a >> b;
  7. for (int i = 0; i < 100; ++i) {
  8. if(a==b) {
  9. temp++;
  10. break;
  11. }
  12. while (a > b) {
  13. a = a - b;
  14. temp++;
  15. }
  16. while (a < b) {
  17. b = b - a;
  18. temp++;
  19. }
  20. }
  21. cout << temp;
  22. }
Success #stdin #stdout 0s 4352KB
stdin
12 8
stdout
3