Problem:


 

イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。

与えられた非負整数nに対し、10進法でp(n) &minus; 1桁の正整数11...1をp(n)で割ったあまりを求めよ。ただしp(n)は22{ . . . 2}（2がn個）より大きい最小の素数を表すとする。p(0) = 2とする。

あなたの仕事は、イクタ君より速くプログラムを完成させることである。

Input

入力は以下の形式で与えられる。

n

問題の入力の非負整数nがあたえられる。

Constraints

入力中の各変数は以下の制約を満たす。

 0 ≤ n 

Output

問題の解を1行に出力せよ。

Sample Input 1

0

Output for the Sample Input 1

1

n=0のとき、p(n) = 2 なので、1 mod 2 = 1 が解となる。

Sample Input 2

1

Output for the Sample Input 2

2

n=1のとき、p(n) = 3 なので、11 mod 3 = 2が解となる。

Sample Input 3

2

Output for the Sample Input 3

1 



Sample input:
0


Sample output:
1

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
if n % 2 == 0:
	print 1
else:
	print 2

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
if n == 1:
  print 2
else:
  print 1

Submission status: Memory Limit Exceeded

Solution code:
import math
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
n = int(raw_input())
pn = 1
for i in range(n):
	if i == 0:
		pn *= 2
	else :
		pn = pn ** 2
prime = sieve(pn * 2)
pn += 1
while 1:
	if prime[pn] == 1:
		break
	pn += 1
print int(format(2**(pn-1)-1, "b")) % pn

Submission status: Accepted

Solution code:
n = int(input())
if n == 0:
    print(1)
elif n == 1:
    print(2)
elif n == 2:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(input())
if n == 0:
    print(1)
elif n == 1:
    print(2)
elif n == 2:
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(raw_input())
if n == 1: print 2
elif n < 3: print 1
else: print 0

Submission status: Accepted

Solution code:
# p(n) = 2^^n より大きい最小の素数 (ただし^^はクヌースの二重矢印記号) と定義したとき、
# x = (10^(p(n)-1)-1)/9 (mod p(n)) を求めよ
# 「フェルマーの小定理」
# pが素数ならば、a^p == a (mod p(n))
# とくに、aとpが互いに素 (gcd(a,p)=1) のとき
# a^p * a^-1 == a * a^-1 (mod p(n))
# a^(p-1) == 1 (mod p)
#
# 9とp(n)が互いに素ならば
# x * 9^-1 = 10^(p(n)-1)-1 (mod p(n))
# 10とp(n)が互いに素ならば
# 10^(p(n)-1) = 1 (mod p(n))
# ゆえに
# x * 9^-1 = 0 (mod p(n))
# p(n)は素数であるから、p(n)>10のとき9とp(n)および10とp(n)は互いに素でありx=0
n = int(input())
if n == 0:
    # 1 mod 2
    print(1)
elif n == 1:
    # 11 mod 3
    print(2)
elif n == 2:
    # 111 mod 5
    print(1)
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(input())

if n == 0 or n == 2:
    print(1)
elif n == 1:
    print(2)
else:
    print(0)

Submission status: Accepted

Solution code:
n=int(input())
if n==0 or n==2:print(1)
else: print(2 if n==1 else 0)

Submission status: Accepted

Solution code:
n=int(input())
if n>3:n=3
print([1,2,1,0][n])

Submission status: Accepted

Solution code:
n=int(input())
print([1,2,1,0][[n,3][n>3]])

Submission status: Accepted

Solution code:
n=int(input())
print(1if n==0else 2//n)

Submission status: Accepted

Solution code:
n = int(input())
if n==0 or n==2:
    print(1)
elif n==1:
    print(2)
else:
    print(0)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        r = 0
        if n == 0 or n == 2:
            r = 1
        elif n == 1:
            r = 2

        rr.append(r)
        break

    return '\n'.join(map(str, rr))


print(main())

Submission status: Accepted

Solution code:
# AOJ 2610: Fast Division
# Python3 2018.6.30 bal4u

ans = [1, 2, 1, 0]
n = int(input())
if n > 2: n = 3
print(ans[n])

Submission status: Accepted

Solution code:
n = int(input())
 
if n == 0 or n == 2:
    print(1)
elif n == 1:
    print(2)
else:
    print(0)

Submission status: Accepted

Solution code:
n=int(input())
if n == 0 or n == 2:
    print(1)
elif n == 1:
    print(2)
else:
    print(0)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    while 1:
        n = I()
        if n == 0:
            quit()
        a = LI()
        m = sum(a)/n
        c = 0
        for i in range(n):
            if a[i] <= m:
                c += 1
        print(c)
    return

#B
def B():
    while 1:
        n = I()
        if n == 0:
            quit()
        t = [0 for i in range(24*3600)]
        for i in range(n):
            x,y = input().split()
            x = list(map(int, x.split(":")))
            y = list(map(int, y.split(":")))
            l = x[0]*3600+x[1]*60+x[2]
            r = y[0]*3600+y[1]*60+y[2]
            t[l] += 1
            t[r] -= 1
        ans = 0
        for i in range(24*3600-1):
            t[i+1] += t[i]
            ans = max(ans, t[i])
        print(ans)
    return
#C
def C():
    n = I()
    if n == 0:
        print(1)
    elif n == 1:
        print(2)
    elif n == 2:
        print(1)
    else:
        print(0)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    C()

Submission status: Runtime Error

Solution code:
import math
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
n = int(raw_input())
pn = 1
for i in range(n):
	pn *= 2
prime = sieve(pn*2)
pn += 1
while 1:
	if prime[pn] == 1:
		break
	pn += 1
print int(format(2**(pn-1)-1, "b")) % pn

Submission status: Runtime Error

Solution code:
import math
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
n = int(raw_input())
pn = 1
for i in range(n):
	pn *= 2
prime = sieve(pn*100)
pn += 1
while 1:
	if prime[pn] == 1:
		break
	pn += 1
print int(format(2**(pn-1)-1, "b")) % pn

Submission status: Runtime Error

Solution code:
import math
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
n = int(raw_input())
pn = 1
for i in range(n):
	pn *= 2
prime = sieve(pn*10)
pn += 1
while 1:
	if prime[pn] == 1:
		break
	pn += 1
print int(format(2**(pn-1)-1, "b")) % pn

Submission status: Runtime Error

Solution code:
n=int(input())
print(n?n>3?0:3-n:1)