시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 1380 842 747 65.873%

문제

1보다 크거나 같고 12보다 작거나 같은 자연수 n이 주어졌을 때, 합이 n이 되는 두 자연수의 쌍을 찾는 프로그램을 작성하시오.

예를 들어, 5가 주어진 경우 가능한 쌍은 1,4와 2,3이 있다. 두 수는 항상 달라야 한다. 즉, 3,3은 올바른 쌍이 아니다. 또, 첫 번째 수가 두 번째 수보다 작아야 한다.

출력하는 쌍은 항상 사전순으로 출력해야 한다. 즉, 각 쌍의 작은 수로 비교를 해야 한다. 예를 들어 1,5는 2,4보다 사전순으로 앞선다.

입력

첫째 줄에 테스트 케이스의 수 (< 100)가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, n이 주어진다.

출력

각 테스트 케이스마다 n을 만드는 쌍을 사전순으로 출력한다. n을 만드는 쌍이 없는 경우에는 아무것도 출력하지 않는다.

예제 출력 형식을 참고해 출력한다.

예제 입력 1

4
2
3
4
5

예제 출력 1

Pairs for 2:
Pairs for 3: 1 2
Pairs for 4: 1 3
Pairs for 5: 1 4, 2 3
W3sicHJvYmxlbV9pZCI6IjUyMTciLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMzMGRcdWM3NTggXHVkNTY5IiwiZGVzY3JpcHRpb24iOiI8cD4xXHViY2Y0XHViMmU0IFx1ZDA2Y1x1YWM3MFx1YjA5OCBcdWFjMTlcdWFjZTAgMTJcdWJjZjRcdWIyZTQgXHVjNzkxXHVhYzcwXHViMDk4IFx1YWMxOVx1Yzc0MCBcdWM3OTBcdWM1ZjBcdWMyMTggblx1Yzc3NCZuYnNwO1x1YzhmY1x1YzViNFx1Yzg0Y1x1Yzc0NCBcdWI1NGMsIFx1ZDU2OVx1Yzc3NCBuXHVjNzc0IFx1YjQxOFx1YjI5NCBcdWI0NTAgXHVjNzkwXHVjNWYwXHVjMjE4XHVjNzU4IFx1YzMwZFx1Yzc0NCBcdWNjM2VcdWIyOTQgXHVkNT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mRlci48XC9wPlxyXG4iLCJpbnB1dCI6IjxwPlRoZSBmaXJzdCBsaW5lIGluIHRoZSB0ZXN0IGRhdGEgbGUgY29udGFpbnMgdGhlIG51bWJlciBvZiB0ZXN0IGNhc2VzICgmbHQ7IDEwMCkuIEFmdGVyIHRoYXQsIGVhY2ggbGluZSBjb250YWlucyBvbmUgdGVzdCBjYXNlOiB0aGUgbnVtYmVyIG4uPFwvcD5cclxuIiwib3V0cHV0IjoiPHA+Rm9yIGVhY2ggdGVzdCBjYXNlLCB5b3UgYXJlIHRvIG91dHB1dCBpbiBsZXhpY29ncmFwaGljIG9yZGVyIHRoZSBkaWZmZXJlbnQgcGFpcnMgb2YgbnVtYmVycyBiZXR3ZWVuIDEgYW5kIDEyIHRoYXQgd2hlbiBzdW1tZWQgcHJvZHVjZSBuLiBJZiB0aGVyZSBhcmUgbm8gc3VjaCBudW1iZXJzLCBkb24mIzM5O3QgcHJpbnQgYW55dGhpbmcuPFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

High School > University of Maryland High School Programming Contest > HSPC 2012 P1번