You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
511 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
int main() {
// 片断
int q = 1, r = 32;
for (int i = 2; i * i <= r; i++) {
while (r % (i * i) == 0) {
q = q * i;
r = r / (i * i);
}
}
cout << q << "*sqrt(" << r << ")" << endl;
// gcd 16/18
int a = 16, b = 18;
cout << a / gcd(a, b) << "/" << b / gcd(a, b) << endl;
return 0;
}