문제 링크
자물쇠가 있고 자물쇠를 푸는 방법이 설명되어 있다.
주어진 방법대로 자물쇠를 풀 때 총 자물쇠를 몇 도 돌려야하는지 풀면 되는 문제
자물쇠를
1. 시계 방향으로 에서 로 돌릴 때
2. 시계 반대 방향으로 에서 로 돌릴 때
로 계산하면 된다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 1000000000
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
while (true) {
int a, b, c, d;
cin >> a >> b >> c >> d;
if (a == 0 && b == 0 && c == 0 && d == 0) break;
int ans = 1080;
int pos;
pos = a;
ans += ((pos - b + 40) % 40) * 9;
pos = b;
ans += ((c - pos + 40) % 40) * 9;
pos = c;
ans += ((pos - d + 40) % 40) * 9;
pos = d;
cout << ans << '\n';
}
}
moduler 연산, 구현 굿