#GL0000321. Khách sạn Hilbert (Hilbert's Hotel)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Khách sạn Hilbert (Hilbert's Hotel)
Hilbert's Hotel
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Hilbert's Hotel has exactly one room numbered for every integer , including negative integers. Initially each room is occupied by exactly one guest.
You are given integers . Simultaneously move the guest in room to room
where is always the remainder in , even for negative .
Determine whether, after all moves, every room is still occupied by exactly one guest, with no empty rooms and no collisions.
Input
Line 1 contains . Line 2 contains exactly integers in index order from to .
Output
Print YES if each room remains occupied by exactly one guest, or NO otherwise.
Subtasks
- Subtask 1 (20 points): ; for all .
- Subtask 2 (30 points): ; for all .
- Subtask 3 (50 points): ; for all .
Examples
Example 1
Input
3
0 0 0
Output
YES
Explanation
Every offset is , so each guest stays in their original room and the assignment remains one-to-one.
Example 2
Input
2
0 1
Output
NO
Explanation
Guests in even rooms stay. The guest in room moves to room , whose original guest does not move, causing a collision and leaving room empty.