P15347 [GeeksforGeeks] Check if the door is open or closed2013
普及-
题目描述

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 i.e. 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.

Example 1:
Input:
N = 3
Output:
1 0 0
Explanation:
Initiall status of rooms - 0 0 0.
Person with id 2 changes room 2 to open,
i.e. (0 1 0). Person with id 1 changes
room 1, 2, 3 status (1 0 1).
Person with id 3 changes room 3
status i.e. (1 0 0).
Example 2:
Input:
N = 2
Output:
1 0
Explanation:
Initiall status of rooms - 0 0.
Person with id 2 changes room 2 to open,
i.e. (0 1). Person with id 1 changes
room 1, 2 status (1 0).

Your Task:
You don't need to read input or print anything. Your task is to complete the function checkDoorStatus() which takes an Integer N as input and returns an array as the answer.

Expected Time Complexity: O(N*sqrt(N))
Expected Auxiliary Space: O(N)

Constraints:
1 <= N <= 10^{4}

输入格式

见题面

输出格式

见题面

样例输入
N = 3
样例输出
1 0 0