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

Seq

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 786    Accepted Submission(s): 330


Problem Description
度度熊有一个递推式 $a_{n} = (\sum_{i=1}^{n-1} a_{i}*i) \% n$
其中 $a_1 = 1$。现给出 $n$,需要求 $a_n$。
 

Input
第一行输入一个整数 $T$,代表 $T~(1 \leq T \leq 100000$) 组数据。
接下 $T$ 行,每行一个数字 $n~(1\leq n \leq 10^{12})$。
 

Output
输出 $T$ 行,每行一个整数表示答案。
 

Sample Input
5 1 2 3 4 5
 

Sample Output
1 1 0 3 0
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 09:02:51, Gzip enabled