diff --git a/easy/day_20/problem.txt b/easy/day_20/problem.txt new file mode 100644 index 0000000..ace608b --- /dev/null +++ b/easy/day_20/problem.txt @@ -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. \ No newline at end of file diff --git a/easy/day_20/sample_test_cases.txt b/easy/day_20/sample_test_cases.txt new file mode 100644 index 0000000..11a1433 --- /dev/null +++ b/easy/day_20/sample_test_cases.txt @@ -0,0 +1,11 @@ +Example + +input +3 +1 +2 +3 +output +1 +1 2 +-1 \ No newline at end of file diff --git a/easy/day_20/solution.cpp b/easy/day_20/solution.cpp new file mode 100644 index 0000000..8d3ad8d --- /dev/null +++ b/easy/day_20/solution.cpp @@ -0,0 +1 @@ +//write your code here \ No newline at end of file