[BOJ] 1188 음식 평론가

Time Lapse :11min 23sec

1188.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
using namespace std;
int n, m;
int gcd(int p, int q){
return q ? gcd(q, p%q) : p;
}

int main(void) {
scanf("%d %d", &n, &m);
int g = gcd(n, m);
m /= g;
cout<<(m - 1) * g;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/05/PS/BOJ/1188/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.