Accepted
Code
#include <bits/stdc++.h>
using namespace std;
long long sir(long long A, long long B) {
long long op = 0;
while (A != 0 && B != 0) {
if (A > B) {
op += A / B;
A %= B;
} else {
op += B / A;
B %= A;
}
}
return op;
}
int main() {
int t;
cin >> t;
while (t--) {
long long A, B;
cin >> A >> B;
long long result = sir(A, B);
cout << result << endl;
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1029 Make it zero
- Contest
- Brain booster #2
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-03-06 14:58:48
- Judged At
- 2024-11-11 03:41:46
- Judged By
- Score
- 100
- Total Time
- 5ms
- Peak Memory
- 552.0 KiB