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

34296번 - Mirror Maze 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB197736.842%

문제

George's birthday is coming up, and his friends are excitedly planning his birthday party. They have already bought his presents and are now planning out the location for the party. After some deliberation, they have decided to host George's party in a mirror maze. Each section of the mirror maze consists of two parallel walls facing each other on which mirrors are placed. This creates the effect of seeing infinite reflections of oneself if you look at one of the walls.

George's friends did some research on how to build mirror mazes, and they discovered that a section of a mirror maze is fun only if the $k$-th reflection of the viewer appears $d$ meters away when the viewer looks at one of the mirrors. George's friends feel confident that they can now build the mirror maze, but they need help figuring out where to put the mirrors so that George will have the most fun. They are planning on building $n$ sections of the maze, and they know when George enters a section of the maze he will be looking to the left. For each section of the maze, they will build a mirror $x$ meters to the left of where George will be and $y$ meters to the right. Because of construction constraints, the distances $x$ and $y$ must be integers between 1ドル$ and 10ドル^9$. Help George's friends figure out where to place the mirrors for each section such that the $k$-th reflection is $d$ meters away or determine it is impossible to place the mirrors to construct a fun section.

입력

The first line of input is $n$ (1ドル \leq n \leq 10^5$), the number of sections in the maze.

Each of the next $n$ lines will consist of two numbers $k$ and $d$ (1ドル \leq k,d \leq 10^9$), where $d$ is the distance in meters where the $k$-th reflection should appear.

출력

Output $n$ lines, one for each section of the maze. For each section, output two numbers, $x$ and $y,ドル the left and right distances of the mirrors, or "impossible" (without quotes) if no combination of left and right distances will result in the $k$-th reflection appearing $d$ meters away.

There may be more than 1ドル$ pair of $x$ and $y$ that satisfy the constraints, you may print any such pair as long as 1ドル \leq x,y \leq 10^9$. It can be shown that if it is possible to place mirrors to create a fun section then there is a pair $x$ and $y$ such that 1ドル \leq x,y \leq 10^9$ which creates a fun section.

제한

예제 입력 1

4
1 6
3 16
2 5
2 10

예제 출력 1

3 1
1 6
impossible
2 3
  • In the first section of the maze, placing a mirror 3 meters to the left will cause the first reflection to appear 6 meters away.
  • In the second section of the maze and by placing the mirrors 1 meter left and 6 meters right, the first reflection appears 2 meters away, the second reflection appears 14 meters away, and the third reflection appears 16 meters away.
  • In the third section of the maze, no combination of integer distances will cause the second reflection to appear 5 meters away.
  • In the fourth section of the maze, the first reflection appears 4 meters away and the second reflection appears 10 meters away.

힌트

출처

School > CS@Mines > CS@Mines HSPC 2025 P번

  • 문제를 만든 사람: Nathan George
(追記) (追記ここまで)

출처

대학교 대회

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

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