Quite the cheater!
Time limit1sMemory limit1024 MB
Given a mean mu and a variance v, build between 10 and 1000 integers whose mean is exactly mu and whose population variance is at least v (or exactly v).
- Level
Medium6 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Statement
Your physics lab report is due tomorrow. You had no time to run the required experiments because you spent all your time practicing for the IPSC, so you decided to write a fake report. A good grade requires the following:
- The report must contain many measurements.
- You already know the correct value you were supposed to measure. The mean of all "measured" values must equal that value.
- The values must look random enough to avoid suspicion. In other words, their variance must be large enough.
You are given integers (the desired mean) and (the desired variance). Pick a number of measurements and values so that the mean is exactly and the variance is at least (easy subproblem) or exactly (hard subproblem). The values must satisfy:
- Each is an integer with .
- The mean is exactly : .
- The variance is .
This is the population variance with , not the unbiased sample variance with , because the mean is known in advance. Use the formula above.
Input
The first line contains an integer , the number of test cases. Each test case is preceded by a blank line.
Each test case is a single line with two integers and . It is guaranteed that , , and .
Output
For each test case, print two lines. The first line contains the number of values . The second line contains the space-separated values . Any valid solution is accepted.
Hint
This sequence of 11 values has mean exactly 47 and variance exactly 2080.