아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Range Partition

시간 제한5초메모리 제한1024 MB

요약
1부터 N까지의 수에서 합이 전체 합의 X/(X+Y)가 되는 부분집합을 찾을 수 있는지 판별하고, 가능하면 그 부분집합을 출력한다.
난이도

보통10점 중 6점

유형
그리디, 수학, 정수론, 구현
정답자
아직 제출이 없습니다

문제

Alan and Barbara suddenly felt like playing with numbers. Alan chooses a non-empty subset from the set of first NN positive integers (1,2,…,N1,2,\dots ,N). Barbara takes the rest of the numbers (if any) from the set. And then they both calculate the sum of the elements in their respective sets.

Alan believes in a magic ratio, which is X:YX:Y. Hence, Alan wants to choose the subset in such a way that the ratio between the sum of Alan's subset and the sum of Barbara's subset is exactly X:YX:Y.

Can you help Alan to choose a subset that can achieve the desired ratio?

입력

The first line of the input gives the number of test cases, TT. TT test cases follow.

Each test case has a single line containing three integers, NN, XX and YY, as described above.

출력

For each test case, output the first line containing Case #x: y, where xx is the test case number (starting from 1) and yy is POSSIBLE, if Alan can choose such a non-empty subset, and IMPOSSIBLE otherwise.

If you print POSSIBLE, then output two more lines for that test case.

In the second line, print a single integer, which denotes the size of Alan's subset.

In the third line, print the integers present in Alan's subset.

If there are multiple solutions, you can print any of them.

제한

  • 1≤T≤1001≤T≤100.
  • 1≤X≤1081≤X≤10^8.
  • 1≤Y≤1081≤Y≤10^8.
  • gcd⁡(X,Y)=1\gcd(X,Y)=1, where gcd is Greatest common divisor.

예제1

  1. 예제 1

    입력
    3
    3 1 2
    3 1 1
    3 1 3
    
    예상 출력
    Case #1: POSSIBLE
    1
    2
    Case #2: POSSIBLE
    2
    1 2
    Case #3: IMPOSSIBLE