반응형
문제
6888번: Terms of Office (acmicpc.net)
6888번: Terms of Office
In CS City, a mathematical place to live, the mayor is elected every 4 years, the treasurer is appointed every 2 years, the chief programmer is elected every 3 years and the dog-catcher is replaced every 5 years. This year, Year $X$, the newly elected mayo
www.acmicpc.net
풀이
2, 3, 4, 5의 최소공배수는 60이므로 60년마다 한번씩 출력하면 됩니다.
#include <iostream>
using namespace std;
int main() {
int X, Y;
cin >> X >> Y;
for (int i = X; i <= Y; i += 60) {
cout << "All positions change in year " << i << "\n";
}
return 0;
}
반응형
'📊 알고리즘' 카테고리의 다른 글
[백준] 14038 - Tournament Selection (C++) (0) | 2023.07.01 |
---|---|
[백준] 21612 - Boiling Water (C++) (0) | 2023.06.30 |
[백준] 10810 - 공 넣기 (C++) (0) | 2023.06.28 |
[백준] 13623 - Zero or One (C++) (0) | 2023.06.27 |
[백준] 21335 - Another Eruption (C++) (0) | 2023.06.26 |