Logo
(追記) (追記ここまで)

13891번 - Find C 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB233474327.564%

문제

Two of your friends Alpha and Beta are at A and B, two integer coordinates in 2D plane. You want to take their picture from another integer coordinate C fulfilling following conditions:

  1. C has to be different from A and B.
  2. There is no integer coordinate point on the line segment AC other than its end points.
  3. There is no integer coordinate point on the line segment BC other than its end points.
  4. Triangle ABC must have positive area, that is, C must not lie on the line going through A and B.
  5. There is no integer coordinate point strictly inside triangle ABC.

Don’t forget this is the era of digital photography where people don’t take only one snap. So you also need to find out K such C for each A and B from where you will take pictures.

A point P having coordinate (x,y) is called integer coordinate if both x and y are integers.

입력

First line of the input contains number of test cases T (1 ≤ T ≤ 1000).

In following T lines, there are 5 integers: Ax, Ay, Bx, By, K. Coordinates of A and B are (Ax, Ay) and (Bx, By) respectively. A and B are distinct points. (-109 ≤ Ax, Ay, Bx, By ≤ 109, 0 ≤ sum of all K ≤ 20 000)

출력

For each case print K lines each containing coordinate of C in: “Cx Cy” format. You may assume that there are at least K such C points. You may output the C points in any order, but these K points has to be distinct. Also all the Cx and Cy have to be between -1014 and 1014. For details of output format please consult the sample input output.

제한

예제 입력 1

2
1 1 10 1 2
0 0 -10 -10 2

예제 출력 1

2 2
3 2
-1 0
-2 -1

힌트

출처

ICPC > Regionals > Asia Pacific > Thailand > 2016 ACM-ICPC Asia-Bangkok Regional Contest D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /