generated from OPCODE-Open-Spring-Fest/template
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3e06c1
commit 6884cdd
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
You have a collection of n bags, each initially containing i candies in the i -th bag. Your aim is to distribute candies such that all bags contain an equal amount. | ||
|
||
To achieve this, you can: | ||
|
||
1. Choose a value m where 1 ≤ m ≤ 1000 . | ||
2. Execute m operations. In each operation j , you'll select one bag and add j candies to all bags except the chosen one. | ||
|
||
Your task is to find a sequence of operations that leads to equal distribution of candies among all bags. It's guaranteed that such a sequence always exists given the constraints. | ||
|
||
Input: | ||
- Each test consists of multiple test cases. | ||
- The first line contains t (where 1 ≤ t ≤ 100 ) — the number of test cases. | ||
- For each test case: a single integer n (where 2 ≤ n ≤ 100 ) representing the number of bags. | ||
|
||
Output: | ||
- For each test case, print two lines: | ||
1. m (where 1 ≤ m ≤ 1000 ) — the number of operations. | ||
2. m positive integers a1, a2, . . ., am (where 1 ≤ ai ≤ n ) indicating the bag chosen in the i -th operation. | ||
|
||
You can output any valid sequence if there are multiple possible solutions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Example | ||
|
||
input | ||
2 | ||
2 | ||
3 | ||
output | ||
1 | ||
2 | ||
5 | ||
3 3 3 1 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//write your code here |