포럼
문제 ICPC00243

J. Jumbled Compass

설명

Jonas is developing the JUxtaPhone and is tasked with animating the compass needle. The API is simple: the compass needle is currently in some direction (between \(0\) and \(359\) degrees, with north being \(0\), east being \(90\)), and is being animated by giving the degrees to spin it.

If the needle is pointing north, and you give the compass an input of \(90\), it will spin clockwise (positive numbers mean clockwise direction) to stop at east, whereas an input of \(-45\) would spin it counterclockwise to stop at north west.

The compass gives the current direction the phone is pointing and Jonas' task is to animate the needle taking the shortest path from the current needle direction to the correct direction. Many ifs, moduli, and even an arctan later, he is still not convinced his minimumDistance function is correct; he calls you on the phone.

제약
입력 형식

The first line of input contains an integer \(n_1\) ($0 \le n_1 \le
359\(), the\ current\ direction\ of\ the\ needle. The\ second\ line\ of\ input\ contains\ an\ integer \)n_2\( (\)0 \le n_2 \le 359$), the correct direction of the needle.

출력 형식

Output the change in direction that would make the needle spin the shortest distance from \(n_1\) to \(n_2\). A positive change indicates spinning the needle clockwise, and a negative change indicates spinning the needle counter-clockwise.

If the two input numbers are diametrically opposed, the needle should travel clockwise. I.e., in this case, output \(180\) rather than \(-180\).

예제 1
입력
315
45
출력
90
예제 2
입력
180
270
출력
90
예제 3
입력
45
270
출력
-135
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC NCPC 2016

평가 및 의견

J. Jumbled Compass

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

J. Jumbled Compass

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8