F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Mod, Xor and Everything

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 949    Accepted Submission(s): 242


Problem Description
You are given an integer $ n $.

You are required to calculate $\text {(n mod 1) xor (n mod 2) xor ... xor (n mod (n - 1)) xor (n mod n). } $

The “ $ xor $ ” operation means “exclusive OR”.
 

Input
The first line contains an integer $ T \left(1 \leq T \leq 5 \right) $ representing the number of test cases.

For each test case, there is an integer $ n \left(1\leq n\leq 10^{12}\right) $ in one line.
 

Output
For each test case, print the answer in one line.
 

Sample Input
5 1 2 3 4 5
 

Sample Output
0 0 1 1 2
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-04-01 06:43:34, Gzip enabled