Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <algorithm>
- #include <iostream>
- using namespace std;
- int GCD(int a, int b)
- {
- if (a > b)
- swap(a, b);
- if (a == 0)
- return b;
- return GCD(b % a, a);
- }
- int NOK(int a, int b) {
- if (a > b)
- swap(a, b);
- if (a == 0)
- return b;
- int c;
- return c = a * b / GCD(a, b);
- }
- int main(){
- int n;
- cin >> n;
- int a;
- int b;
- for (int i = 0; i < n; ++i) {
- int a;
- int b;
- cin >> a >> b;
- cout << NOK(a, b) / a <<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement