시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 1493 663 616 46.880%

문제

상근이는 덧셈과 나눗셈을 엄청나게 못한다. 이런 상근이를 위해 정인이는 상근이에게 다음과 같은 문제를 냈다.

정인이는 양의 정수 A,B,C,D로 이루어진 2*2 표를 그렸다.

A B
C D

위와 같은 표가 있을 때, 표의 값은 A/C + B/D 이다.

상근이는 표를 몇 번 돌리면 표의 값이 최대가 되는지 궁금해졌다.

표는 90도 시계방향으로 돌릴 수 있다.

문제 상단의 표를 1번 회전 시키면 다음과 같다.

C A
D B

2번 회전 시키면 다음과 같이 된다.

D C
B A

표에 써 있는 A,B,C,D가 주어졌을 때, 표를 몇 번 회전시켜야 표의 값이 최대가 되는지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 A와 B가 공백으로 구분되어 주어진다. 둘째 줄에 C와 D가 공백으로 구분되어 주어진다. 모든 수는 100보다 작거나 같은 양의 정수이다.

출력

첫째 줄에 표를 몇 번 돌려야 표의 값이 최대가 되는지 출력한다. 만약, 그러한 값이 여러개라면 가장 작은 값을 출력한다.

예제 입력 1

1 2
3 4

예제 출력 1

2
W3sicHJvYmxlbV9pZCI6IjI4NjMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM3NzRcdWFjOGMgXHViZDg0XHVjMjE4PyIsImRlc2NyaXB0aW9uIjoiPHA+XHJcblx0XHVjMGMxXHVhZGZjXHVjNzc0XHViMjk0IFx1YjM2N1x1YzE0OFx1YWNmYyBcdWIwOThcdWIyMTdcdWMxNDhcdWM3NDQgXHVjNWM0XHVjY2FkXHViMDk4XHVhYzhjIFx1YmFiYlx1ZDU1Y1x1YjJlNC4gXHVjNzc0XHViN2YwIFx1YzBjMVx1YWRmY1x1Yzc3NFx1Yjk3YyBcdWM3MDRcdWQ1NzQgXHVjODE1XHVjNzc4XHVjNzc0XHViMjk0IFx1YzBjMVx1YWRmY1x1Yzc3NFx1YzVkMFx1YWM4YyBcdWIyZTRcd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uXHJcbjxwPkFsbCBpbnRlZ2VycyBhcmUgcG9zaXRpdmUgYW5kIG5vdCBncmVhdGVyIHRoYW4gMTAwLiZuYnNwOzxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPlRoZSBmaXJzdCBhbmQgb25seSBsaW5lIG9mIG91dHB1dCBtdXN0IGNvbnRhaW4gYSBzaW5nbGUgaW50ZWdlciwgbWluaW11bSBudW1iZXIgb2YgY2xvY2t3aXNlIHJvdGF0aW9ucyByZXF1aXJlZCB0byBtYXhpbWl6ZSB0aGUgdGFibGUmcnNxdW87cyB2YWx1ZS48XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

Contest > Croatian Open Competition in Informatics > COCI 2010/2011 > Contest #3 1번

  • 문제를 번역한 사람: baekjoon
  • 문제의 오타를 찾은 사람: joonas