반응형 최대공배수1 백준 1735번 - 분수 합 (C++) 문제 문제 풀이 두 분수를 더하고, 최소공약수를 구해주면 된다. 코드 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #include using namespace std; int gcd(int a, int b) { int r; while (b != 0) { r = a % b; a = b; b = r; } return a; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int a, s, d, f; cin >> a >> s >> d >> f; a *= f; d *= s; a += d; s *= f; int GCD = .. 2021. 5. 5. 이전 1 다음 반응형