#P8447. 「FAOI-R1」完美的平方数
「FAOI-R1」完美的平方数
Problem Description
Given a positive integer . There are queries. In each query, a positive integer is given. You need to pick some numbers from (the same number may be picked multiple times) such that their sum is exactly . Find the minimum number of picked numbers. (If there is no solution, output .)
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , representing the number of test cases.
For each test case:
The first line contains two positive integers .
The next lines each contain one positive integer .
Output Format
For each query in each test case, output one line with one positive integer, which is the answer.
5
1 5
1
2
3
4
5
5 5
8
20
25
37
49
11 1
179
13 1
507
19 1
841
1
2
3
4
5
2
2
1
4
4
3
3
4
Hint
Sample explanation:
For the first test case, obviously the answer is , because you can only pick .
For the second test case:
- ;
- ;
- ;
- ; (or )
- ; (or )
- Note that and are both invalid, because in this test case .
| Test Point ID | Score | ||
|---|---|---|---|
For of the testdata, , , , . In a single test point, the sum of over all test cases () satisfies .
Translated by ChatGPT 5