Given n doors and n persons. The doors are numbered from 1 to n and persons are given id’s numbered from 1 to n. Each door can have only two statuses ie open (1) or closed (0) . Initially all the doors have status closed. Find the final status of all the doors, when all the persons have changed the status of the doors of which they are authorized. i.e. if status open then change the status to closed and vice versa. A person with id ‘i’ is authorized to change the status of door numbered ‘j’ if ‘j’ is a multiple of ‘i’.
Note: A person has to change the current status of all the doors for which he is authorized exactly once.
Input : 3
Output : 1 0 0
Explanation : Initially status of rooms 0 0 0 person with id 2 changes room 2 to open ie (0 1 0) person with id 1 changes room 1, 2, 3 status (1 0 1) person with id 3 changes room 3 status ie (1 0 0)
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer n.
For each test case in a new line print the n space separated integers either (1 or 0) depending on the status of the ith door where 1 denotes the door is open and a 0 denotes door is closed.
1 <= T <= 100
1 <= N <= 1000
1 0 0
1 0 0 1 0
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.