Different Subarray Sum Problem

2.7

44 votes
Number Theory, Modulus Arithmetic, Math, C++, Number theory
Problem

You are given positive integer . Construct any array , such that:

  • For all pairs  such that , the values of  should be distinct.

Input format 

  • The single line  contains integer  - the length of the array.

Output format

  • Find any array such that all of the conditions are hold.

Constraints

  •     
Sample Input
5
Sample Output
1 2 4 8 16
Time Limit: 3
Memory Limit: 256
Source Limit:
Explanation

Subarray sums are: . . So you can see what, all the numbers are different.

Editor Image

?