hiho week 92 register

Ended

Participants:3918

Verdict:Accepted
Score:100 / 100
Submitted:2016-04-07 17:31:27

Lang:Python2

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def powmod(a,n,d):
    if n==1:
        return a % d;
    if n & 1:
        return (powmod(a*a%d,n/2,d)*a)%d;
    else:
        return (powmod(a*a % d,n/2,d)%d);
def isPrime(n):
    a=[2,3,5,7,11,13,17,19,23,29];
    for i in range(len(a)):
        if a[i]>=n:
            break;
        u=n-1;
        temp=powmod(a[i],u,u+1);
        if temp!=1:
            return False;
        while u^1==0:
            if u==0:
                break;
            u=u/2;
            temp=powmod(a[i],u,u+1);
            if temp!=1:
                return False;
    return True;
# print powmod(3,100000,888);
# print isPrime(1234567894987654321);
n=int(raw_input());
for i in range(n):
    x=int(raw_input());
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX