generated from OPCODE-Open-Spring-Fest/template
-
Notifications
You must be signed in to change notification settings - Fork 27
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
831c4cf
commit 2db56d9
Showing
3 changed files
with
30 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,18 @@ | ||
Imagine you're handed a positive integer n . | ||
|
||
Your task is to construct a permutation a1, a2, . . ., an such that for any pair of indices l and r where 1 ≤ l < r ≤ n , the sum al + a{l+1} + . . . + ar is never divisible by r - l + 1 . | ||
|
||
In simpler terms, you need to create a sequence where no consecutive subsequence of elements sums up to a number divisible by the length of that subsequence plus one. | ||
|
||
For instance, if n = 5 , a valid permutation could be [3, 2, 5, 4, 1] because: | ||
- 3 + 2 = 5 is not divisible by 2 + 1 = 3 , | ||
- 2 + 5 = 7 is not divisible by 2 + 1 = 3 , | ||
- 5 + 4 = 9 is not divisible by 2 + 1 = 3 , and so on. | ||
|
||
Input: | ||
- The number of test cases t ( 1 ≤ t ≤ 100 ). | ||
- For each test case: an integer n ( 1 ≤ n ≤ 100 ), the size of the permutation. | ||
|
||
Output: | ||
- If no such permutation exists, print -1. | ||
- Otherwise, print n distinct integers p1, p2, . . ., pn ( 1 ≤ pi ≤ n ) representing a permutation satisfying the given condition. If multiple solutions exist, any valid permutation is acceptable. |
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 | ||
3 | ||
1 | ||
2 | ||
3 | ||
output | ||
1 | ||
1 2 | ||
-1 |
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 |