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

32495번 - XY 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 1024 MB104466.667%

문제

Kaloyan was preparing an exam for his students and found the following problem to be pretty interesting. He wrote two numbers $X$ and $Y$ and wants to find a sequence of integers where the sum of every $X$ consecutive elements (in the sequence) is strictly positive while the sum of every $Y$ consecutive elements is strictly negative.

Kaloyan found out that this sequence cannot be infinitely long. He tried to find a sequence of maximum possible length with the described property. However, it turns out to be rather difficult problem for Kaloyan. Help him by writing a program XY that finds the maximum length of such a sequence. You should find the answers to $Q$ such pairs $X$ and $Y$. Additionally, you have to find a maximal sequence only for the first query.

입력

The only line of the standard input contains one number $Q$ - the number of queries. Each of the following $Q$ lines contains two numbers - $X$ and $Y$ .

출력

On the first line of the standard output you should print $Q$ numbers - $N_1, N_2, \dots, N_Q,ドル separated with intervals, where $N_i$ is the answer for the $i^{th}$ query. On the second line you should print $N_1$ integers separated with intervals - a sequence with the desired property for the first query.

제한

  • 1ドル \leq X,Y \leq 100\ 000$
  • 1ドル \leq Q \leq 100\ 000$

서브태스크

Subtasks Points Required subtasks Other constraints
1 3 For every query: $x=y$
2 4 1 For every query: $x$ divides $y$ or $y$ divides $x$
3 9 $X,Y \leq 5,ドル $Q=1$
4 12 $|X-Y| = 1$
5 15 3 $X,Y,Q \leq 100$
6 22 3, 5 $X,Y,Q \leq 10000$
7 35 1, 2, 3, 4, 5, 6 No additional constraints.

예제 입력 1

3
3 5
1 5
4 2

예제 출력 1

6 4 3
5 -7 5 3 -7 5

힌트

출처

Olympiad > International Autumn Tournament in Informatics > 2024 > Junior 6번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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