Problem:


Score : 600 points

Problem Statement

Given is a positive integer N.

We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.

Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.

In how many choices of K will N become 1 in the end?

Constraints

2 \leq N \leq 10^{12}

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of choices of K in which N becomes 1 in the end.

Sample Input 1

6

Sample Output 1

3

There are three choices of K in which N becomes 1 in the end: 2, 5, and 6.

In each of these choices, N will change as follows:

When K=2: 6 \to 3 \to 1

When K=5: 6 \to 1

When K=6: 6 \to 1

Sample Input 2

3141

Sample Output 2

13

Sample Input 3

314159265358

Sample Output 3

9



Sample input:
6


Sample output:
3

Submission status: Wrong Answer

Solution code:
def numbers(n):
	if n == 2:
		return 1
	ans = 0
	i = 2
	while(i * i <= n):
		temp = n
		while(temp % i == 0):
			temp /= i
		if temp % i == 1:
			ans += 1
		i += 1
	p = n - 1
	f = 1
	i = 2
	while(i * i <= n):
		count = 0
		while p % i == 0:
			p /= i
			count += 1
		if n % i != 0 and count != 0:
			f *= (count + 1)
		i += 1
	return ans + f + 1


num = int(input())
print(numbers(num))

Submission status: Wrong Answer

Solution code:
def divisors(n):
  small = []
  large = []
  i = 1
  while i * i <= n:
    if not n % i:
      small.append(i)
      large.append(n // i)
    i += 1
  if small[-1] == large[-1]:
    large.pop()
  return small + large[::-1]

n = int(input())
res = set(divisors(n - 1))
res.remove(1)

for d in divisors(n):
  if d == 1:
    continue
  now = n
  # simulation
  while not now % d:
    now //= now
  if now % d == 1:
    res.add(d)

print(len(res))

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n=int(input())
l1=make_divisors(n-1)
l2=make_divisors(n)[2:]
for i in l2:
  j=n/i
  while j%i==0:
    j/=i
  if j%i==1 and j not in l1:
    l1.append(j)
print(len(l1))

Submission status: Wrong Answer

Solution code:
# 素因数分解

N=int(input())
cand=[]

def check(N0,K0):
    if N0%K0==0:
        return check(int(N0/K0),K0)
    elif N0%K0==1:
        return 1
    else:
        return 0

def check0(N0,K0):
    while N0%K0==0:
        N0=int(N0/K0)
    if N0%K0==1:
        return 1
    else:
        return 0

# N-1の約数の数
for i in range(2,int((N-1)**0.5)+1):#O(N**0.5)
    if (N-1)%i==0:
        cand.append(i)
        if i!=int((N-1)/i):
            cand.append(int((N-1)/i))
if N>2:
    cand.append(N-1)

# Nの約数
for i in range(2,int(N**0.5)+1):#O(N**0.5)
    if N%i==0:
        cand.append(i)
        if i!=int(N/i):
            cand.append(int(N/i))
cand.append(N)

print(cand)
count=0
for i in range(len(cand)):
    if check(N,cand[i]):
        count+=1

print(count)

Submission status: Wrong Answer

Solution code:
# 素因数分解

N=int(input())
cand=[]

def check(N0,K0):
    if N0%K0==0:
        return check(int(N0/K0),K0)
    elif N0%K0==1:
        return 1
    else:
        return 0

def check0(N0,K0):
    while N0%K0==0:
        N0=int(N0/K0)
    if N0%K0==1:
        return 1
    else:
        return 0

# N-1の約数の数
for i in range(2,int((N-1)**0.5)+1):#O(N**0.5)
    if (N-1)%i==0:
        cand.append(i)
        cand.append(int((N-1)/i))
if N>2:
    cand.append(N-1)
    
# Nの約数
for i in range(2,int(N**0.5)+1):#O(N**0.5)
    if N%i==0:
        cand.append(i)
        cand.append(int(N/i))
cand.append(N)


count=0
for i in range(len(cand)):
    if check(N,cand[i]):
        count+=1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [n]
if n != 2:
    a.append(n - 1)

def div_(N, k):
    while N % k == 0:
        N /= k
    if N % k == 1:
        a.append(k)

for k in range(2, int(n ** 0.5) + 1):
    if n % k == 0:
        div_(n,k)
        if k != n / k:
            div_(n, n // k)

    if (n - 1) % k == 0:
        a.append(k)
        if k != (n - 1) / k:
            a.append((n - 1) // k)

print(a)
print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [n]
if n != 2:
    a.append(n - 1)

def div_(N, k):
    while N % k == 0:
        N /= k
    if N % k == 1:
        a.append(k)

for k in range(2, int(n ** 0.5) + 1):
    N = n
    if N % k == 0:
        div_(N,k)
        if k != N / k:
            div_(N, N / k)
    
    elif (N - 1) % k == 0:
        a.append(k)
        if k != N / k:
            a.append((N - 1) / k)

print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())

if n == 2:
    a = []
else:
    a = [n - 1, n]

def div_(N, k):
    while N % k == 0:
        N /= k
    if N % k == 1:
        a.append(k)

for k in range(2, int(n ** 0.5) + 1):
    N = n
    if N % k == 0:
        div_(N,k)
        if k != N / k:
            div_(N, N / k)
    
    elif (N - 1) % k == 0:
        a.append(k)
        if k != N / k:
            a.append((N - 1) / k)

print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
def factorize(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.append(n)
    return divisors

def check(num, mod):
    if num % mod == 1:
        return 1
    elif num % mod == 0:
        num = num / mod
        return check(num, mod)
    else:
        return 0


nfct = factorize(n)
n_1fct = factorize(n - 1)

ans += len(n_1fct)
for mod in nfct:
  ans += check(n,mod)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())


def check(n, k):
    while n % k == 0:
        n = n // k
    if n >= k:
        n = n - k * (n // k)
    return n


def count(n):
    total = 0
    cands = set([n, n-1])
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cands.add(i)
            cands.add(n // i)
    for i in range(2, int(n ** 0.5) + 1):
        if (n-1) % i == 0:
            cands.add(i)
            cands.add((n - 1) // i)
    for k in cands:
        if k == 1:
            continue
        if check(n, k) == 1:
            total += 1
    return total

Submission status: Wrong Answer

Solution code:
n = int(input())

a = []
for k in range(1, int(n ** 0.5) + 1):
    N = n
    if k == 1:
        a.append(n - 1)
        a.append(n)
    elif N % k == 0:
        N = N / k
        while N >= k:
            if N % k == 0:
                N = N / k          
            elif N % k == 1:
                a.append(k)
                break
            else:
                break
    
    elif (N - 1) % k == 0:
        a.append(k)
        if k != N / k:
            a.append((N - 1) // k)

print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())

a = []
for k in range(1, int(n ** 0.5) + 1):
    N = n
    if k == 1:
        a.append(n - 1)
        a.append(n)
    elif N % k == 0:
        N = N / k
        while N >= k:
            if N % k == 0:
                N = N / k          
            elif N % k == 1:
                a.append(k)
                break
            else:
                break
    
    elif (N - 1) % k == 0:
        a.append(k)
        if k != N / k:
            print((N - 1) // k)
            a.append((N - 1) // k)

print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
n_ = n-1
a = [n]
a_ = [n_]
    
for i in range(2,int(n**0.5//1+1)):
    if n%i == 0:
        a.append(i)
        if n/i != i:
            a.append(n/i)
    if n_%i == 0:
        a_.append(i)
        if n_/i != i:
            a_.append(n_/i)

ans = len(a_)
for i in a:
    num = n
    while num%i == 0:
        num /= i
    if num % i == 1:
        ans += 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input()) 
times = 0

def make_divisors(n):
    divisors = [n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors
    
times = len(make_divisors(n - 1))
a = make_divisors(n)

for i in a:
    tmp = n // i
    if tmp == 1:
        times += 1 
        continue
    while tmp % i == 0:
        tmp = tmp // i
    if tmp % i == 1:
        times += 1 
    
print(times)

Submission status: Wrong Answer

Solution code:
from math import sqrt
from fractions import gcd
from collections import Counter

n = int(input()) 
times = 0

# 素因数分解
def gcd(tmpn):
    lists = []
    while True:
        end = True
        for i in range(2, int(sqrt(tmpn)) + 1):
            if tmpn % i == 0:
                lists.append(i)
                tmpn = tmpn // i
                end = False         
        if end:  
            lists.append(tmpn)
            break
    return lists

# 公約数
def gori(lists, num=1, ans=[]):
    if len(lists) == 0:
        ans.append(num)
        return ans
    for i in range(len(lists)):
        tmp = lists[0:i] + lists[i + 1:len(lists)]
        ans = gori(tmp, num * lists[i], ans)
        ans = gori(tmp, num, ans)
    return ans

# 1を除いた公約数の個数を出力する
a = Counter(gcd(n - 1))
times = sum(map(lambda x: x+1, a.values())) - 1

a = set(gori(gcd(n)))
a.remove(1)

for i in a:
    tmp = n // i
    if tmp < i:
        if tmp == 1:
            times += 1
        
    else:
        while True:
            if tmp < i:
                if tmp == 1:
                    times += 1
                    break
            if tmp % i == 0:
                tmp = int(tmp / i)
                    
            else:
                if tmp % i == 1:
                    times += 1
                break

print(times)

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    div=[n]
    for i in range(2,-int(-n**0.5//1)):
        if n%i==0:
            div.append(i)
            div.append(n//i)
    if n%(n**0.5)==0:
        div.append(int(n**0.5))
    div.sort()
    return div

n=int(input())
ans=make_divisors(n-1)
for i in make_divisors(n):
    a=n
    while a%i==0:
        a=a//i
    if a%i==1:
        ans.append(i)
print(len(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 1

for k in range(2, int(n ** 0.5) + 1):
    if n % k != 0:
        continue
    if (n // k) % k == 1:
        ans += 1
for i in range(2, 41):
    for k in range(2, n + 1):
        x = k ** i
        if x > n:
            break
        if n % x != 0:
            continue
        if (n // x) % k == 1:
            ans += 1
n -= 1
for k in range(1, int(n ** 0.5) + 1):
    if n % k != 0:
        continue
    if (k * k == n or k == 1) and n // k != 1:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 1

for k in range(2, int(n ** 0.5) + 1):
    if n % k != 0:
        continue
    if (n // k) % k == 1:
        ans += 1
for i in range(2, 41):
    for k in range(2, n + 1):
        x = k ** i
        if x > n:
            break
        if n % x != 0:
            continue
        if (n // x) % k == 1:
            ans += 1
n -= 1
for k in range(1, int(n ** 0.5) + 1):
    if n % k != 0:
        continue
    if k * k == n or k == 1:
        ans += 1
    else:
        ans += 2
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

tmp=make_divisors(n-1)
tmp.remove(1)
tmp.append(n)
if not 2 in tmp:
    tmp.append(2)

print(len(tmp))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
B = []
for i in range(2,int(N**0.5)+1):
    if N%i==0:
        A.append(i)
        A.append(N//i)
    if (N-1)%i==0:
        B.append(i)
        B.append((N-1)//i)
A.append(N)
B.append(N-1)
A = sorted(A)
for a in A:
    m = 1
    while True:
        if a**m==N:
            B.append(a)
            break
        elif a**m>N:
            break
        m += 1
for a in A:
    m=0
    while a**m<N:
        if N%a**m==0:
            if (N//(a**m)-1)%a==0:
                B.append(a)
        m += 1
B = sorted(list(set(B)))
print(len(B))

Submission status: Wrong Answer

Solution code:
N = int(input())

divisor = [N]
ans = 0

#Nの約数の列挙
for i in range(2,N+1,1):
    if i*i < N:
        if N % i == 0:
            divisor.append(i)
            divisor.append(N//i)
    elif i*i == N:
        divisor.append(i)
    else:
        break

#N-1の約数の列挙
yakusuuu = [N-1]
for i in range(2,N,1):
    if i*i < (N-1):
        if (N - 1)% i == 0:
            yakusuuu.append(i)
            yakusuuu.append((N-1)//i)
    elif i*i == N:
        yakusuuu.append(i)
    else:
        break

for i in yakusuuu:
    if N % i == 1:
        ans += 1

#print(divisor)
#print(yakusuuu)

M = N

for K in divisor:
    #print(K)
    while M % K == 0:
        M = M//K

    

    if M == 1:
        ans += 1
        
    else:
        M =  M % K
        if M == 1:
            ans += 1 
    
    M = N
        




print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

divisor = [N]
ans = 0

#Nの約数の列挙
for i in range(2,N+1,1):
    if i*i < N:
        if N % i == 0:
            divisor.append(i)
            divisor.append(N//i)
    elif i*i == N:
        divisor.append(i)
    else:
        break

#N-1の約数の列挙
yakusuuu = [N-1]
for i in range(2,N,1):
    if i*i < N:
        if (N - 1)% i == 0:
            yakusuuu.append(i)
            yakusuuu.append((N-1)//i)
    elif i*i == N:
        yakusuuu.append(i)
    else:
        break

for i in yakusuuu:
    if N % i == 1:
        ans += 1

#print(divisor)
#print(yakusuuu)

M = N

for K in divisor:
    #print(K)
    while M % K == 0:
        M = M//K#ここで全部N==1になっちゃう

    

    if M == 1:
        ans += 1
        
    else:
        M =  M % K
        if M == 1:
            ans += 1 
    
    M = N
        




print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

divisor = [N]
ans = 0

#Nの約数の列挙
for i in range(2,N+1,1):
    if i*i < N:
        if N % i == 0:
            divisor.append(i)
            divisor.append(N//i)
    elif i*i == N:
        divisor.append(i)
    else:
        break

#N-1の約数の列挙
yakusuuu = [N-1]
for i in range(2,N,1):
    if i*i < N:
        if N % i == 1:
            yakusuuu.append(i)
            yakusuuu.append((N-1)//i)
    elif i*i == N:
        yakusuuu.append(i)
    else:
        break

for i in yakusuuu:
    if N % i == 1:
        ans += 1

#print(divisor)
#print(yakusuuu)

M = N

for K in divisor:
    #print(K)
    while M % K == 0:
        M = M//K#ここで全部N==1になっちゃう

    

    if M == 1:
        ans += 1
        
    else:
        M =  M % K
        if M == 1:
            ans += 1 
    
    M = N
        




print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

divisor = [N]
ans = 0

#Nの約数の列挙
for i in range(2,N+1,1):
    if i*i <= N:
        if N % i == 0:
            divisor.append(i)
            divisor.append(N//i)
    else:
        break

#N-1の約数の列挙
yakusuuu = [N-1]
for i in range(2,N,1):
    if i*i <= N:
        if N % i == 1:
            yakusuuu.append(i)
            yakusuuu.append((N-1)//i)
    else:
        break

for i in yakusuuu:
    if N % i == 1:
        ans += 1

#print(divisor)
#print(yakusuuu)

M = N

for K in divisor:
    #print(K)
    while M % K == 0:
        M = M//K#ここで全部N==1になっちゃう

    

    if M == 1:
        ans += 1
        
    else:
        M =  M % K
        if M == 1:
            ans += 1 
    
    M = N
        




print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

divisor = [N]
ans = 0

#Nの約数の列挙
for i in range(2,N+1,1):
    if i*i <= N:
        if N % i == 0:
            divisor.append(i)
            divisor.append(N//i)
    else:
        break

#N-1の約数の列挙
yakusuuu = [N-1]
for i in range(2,N,1):
    if i*i <= N:
        if N % i == 1:
            yakusuuu.append(i)
            yakusuuu.append((N-1)//i)
    else:
        break
for i in yakusuuu:
    if N % i == 1:
        ans += 1

#print(divisor)
#print(yakusuuu)

n=N

for K in divisor:
    #print(K)
    for i in range(N):
        if n % K == 0:
            n = n//K#ここで全部N==1になっちゃう
        else:
            break
    

    if N == 1:
        ans += 1
        
    else:
        n %= K
        if n == 1:
            ans += 1 
    n =N
    
        




print(ans)

Submission status: Wrong Answer

Solution code:
#関数f:入力xの1以外の約数をリストで出力
def f(x):
  out=set() #約数を保存するセット
  for i in range(1, int(pow(x, 1/2))):
    #1-x**(1/2)未満の整数iについて、xを割り切れるか判定
    if x%i==0:
      #xをiで割り切れるのであれば、iとx/iを保存
      out.add(i)
      out.add(x//i)
      
  #x**(1/2)でxを割り切れる(つまりxが平方数)なら、出力にx**(1/2)を追加
  if x%(x**(1/2))==0:
    out.add(x**(1/2))
    
  #セットから昇順のリストに変換します
  out=list(out)
  out.sort()
  
  #昇順にした結果1が先頭に来ているため、インデックス1以降を出力
  return out[1:]

#入力受け取り
N=int(input())
ans=0 #最後に出力する変数

for K in f(N): #Nの1以外の約数について、操作の結果1になるかをそれぞれ調べる
    x=N #Nを直接書き換えると後に影響するため、ここではxとする
    #xをKで割り切れる間は、Kで割り続ける
    while x%K==0:
      x/=K
      
    #xをKで割り切れなくなったら、xからKを引けるだけ引く(=割って余りをとる)
    x%=K
    
    #操作後x=1となったならば、出力に1を足す
    if x==1:
        ans+=1
        
#(N-1)の1を除いた約数はすべて条件を満たすため、出力にf(N-1)の要素数を足す
ans+=len(f(N-1))

#出力
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=0
nmcc=0
i=1
d=[]
while i*i<n:
  if n%i==0:
    d.append(i)
    if i*i!=n:
      d.append(n//i)
  i+=1
for i in d:
  if i==1:
    continue
  tmp=n
  while tmp%i==0:
    tmp//=i
  tmp%=i
  if tmp==1:
    ans+=1

i=1
while i*i<(n-1):
  if (n-1)%i==0:
    nmcc+=1
    if i*i!=n-1:
      nmcc+=1
  i+=1
nmcc-=1
print(ans+nmcc)

Submission status: Wrong Answer

Solution code:
import math

def main():
	n=int(input())
	less=n-1
	sett=[]
	sett.append(n)
	if n!=2:
		sett.append(less)
	for i in range(2,math.ceil(math.sqrt(less))+1):
		if less%i==0:
			sett.append(i)
	for i in range(2,math.ceil(math.sqrt(n))+1):
		newn=n
		while newn%i==0:
			newn//=i
		if newn%i==1:
			sett.append(i)
	print(len(set(sett)))
main()

Submission status: Wrong Answer

Solution code:
import math

def main():
	n=int(input())
	less=n-1
	sett=[]
	sett.append(n)
	sett.append(less)
	for i in range(2,math.ceil(math.sqrt(less))+1):
		if less%i==0:
			sett.append(i)
	for i in range(2,math.ceil(math.sqrt(n))+1):
		newn=n
		while newn%i==0:
			newn//=i
		if newn%i==1:
			sett.append(i)
	print(len(sett))
main()

Submission status: Wrong Answer

Solution code:
N = int(input())

divisor = [N]
ans = 0

#Nの約数の列挙
for i in range(2,N+1,1):
    if i*i <= N:
        if N % i == 0:
            divisor.append(i)
            divisor.append(N//i)

#N-1の約数の列挙
yakusuuu = [N-1]
for i in range(2,N,1):
    if i*i <= N:
        if N % i == 1:
            yakusuuu.append(i)
            yakusuuu.append((N-1)//i)

for i in yakusuuu:
    if N % i == 1:
        ans += 1

#print(divisor)
#print(yakusuuu)

for K in divisor:
    #print(K)
    for i in range(N):
        if N % K == 0:
            N = N//K#ここで全部N==1になっちゃう
        else:
            break
    

    if N == 1:
        ans += 1
        
    else:
        N %= K
        if N == 1:
            ans += 1 
        




print(ans)

Submission status: Wrong Answer

Solution code:
# 素因数分解

N=int(input())
cand=[]

def check(N0,K0):
    if N0%K0==0:
        return check(int(N0/K0),K0)
    elif N0%K0==1:
        return 1
    else:
        return 0

def check0(N0,K0):
    while N0%K0==0:
        N0=int(N0/K0)
    if N0%K0==1:
        return 1
    else:
        return 0

# N-1の約数の数
for i in range(2,int((N-1)**0.5)+1):#O(N**0.5)
    if (N-1)%i==0:
        cand.append(i)
        cand.append(int((N-1)/i))

# Nの約数
for i in range(2,int(N**0.5)+1):#O(N**0.5)
    if N%i==0:
        cand.append(i)
        cand.append(int(N/i))
cand.append(N)
if N>2:
    cand.append(N-1)

count=0
for i in range(len(cand)):
    if check(N,cand[i]):
        count+=1

print(count)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N = II()
    def divisors(x):
        r1 = deque()
        r2 = deque()
        for i in range(1,int(x**0.5)):
            if x % i == 0:
                r1.append(i)
                r2.appendleft(x//i)
        if int(x**0.5) == x**0.5:
            r1.append(int(x**0.5))
        return list(r1)+list(r2)
    #N-1の約数
    ans = len(divisors(N-1))-1
    

    for d in divisors(N)[1:]:
        tmpN = N
        while tmpN % d == 0:
            tmpN //= d
        if tmpN % d == 1:
            ans += 1

            
            
    print(ans)


    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 素因数分解

N=int(input())
cand=[]

def check(N0,K0):
    if N0%K0==0:
        return check(int(N0/K0),K0)
    elif N0%K0==1:
        return 1
    else:
        return 0

def check0(N0,K0):
    while N0%K0==0:
        N0=int(N0/K0)
    if N0%K0==1:
        return 1
    else:
        return 0

# N-1の約数の数
for i in range(2,int((N-1)**0.5)+1):#O(N**0.5)
    if (N-1)%i==0:
        cand.append(i)
        cand.append(int((N-1)/i))

# Nの約数
for i in range(2,int(N**0.5)+1):#O(N**0.5)
    if N%i==0:
        cand.append(i)
        cand.append(int(N/i))
cand.append(N)
cand.append(N-1)

count=0
for i in range(len(cand)):
    if check0(N,cand[i]):
        count+=1

print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
count=0
for i in range(2,N+1) :
  
  if (N-1)%i==0 :
    if float(N-1)/i<float(i) :
      if float(N-1)/i==float(1) :
      	count+=1
      else :
        count+=2
      
    elif float(N-1)/i==float(i) :
      count+=1
      
    else :
      
      break
list1=[]
for i in range(2,N+1) :
  if (N-1)%i==0 :
    if float(N-1)/i<float(i) :
      if float(N-1)/i==float(1) :
      	list1.append(N-1)
      else :
        list1.appnd(i)
        list1.appnd(int((N-1)/i))
      
    elif float(N-1)/i==float(i) :
      list1.appnd(i)
      
    else :
      
      break
for youso in list1 :
  
  if N%youso==0 :
    n1=N
    while (n1%youso==0) :
      n1=n1/youso
    if n1%youso==1 :
      count+=1
  
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
def ele(n):
    L = [n]
    for i in range(2, int(n**0.5)+1):
        cur = n
        while cur%i == 0:
            cur = cur//i
            L.append(i)
            L.append(n//i)
    L = list(set(L))
    return L
ans = ele(n-1)
t = ele(n)
for i in range(len(t)):
    temp = n
    while temp%t[i] == 0:
        temp = temp//t[i]
    if temp%t[i] == 1:
        ans.append(t[i])
print(len(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
count=0
for i in range(2,N+1) :
  
  if (N-1)%i==0 :
    if float(N-1)/i<float(i) :
      if float(N-1)/i==float(1) :
      	count+=1
      else :
        count+=2
      
    elif float(N-1)/i==float(i) :
      count+=1
      
    else :
      
      break
  
for i in range(2,N+1) :
  
  if N%i==0 :
    n1=N
    while (n1%i==0) :
      n1=n1/i
    if n1%i==1 :
      count+=1
  
print(count)

Submission status: Wrong Answer

Solution code:
import math

def get_divisor(n):
    sn = math.sqrt(n)
    i = 1
    divisor = []
    while i <= sn:
        if n % i == 0:
            divisor.append(i)
            divisor.append(n // i)
        i += 1
    return divisor

n = int(input())
if n == 2:
    print(1)
    exit()
d1 = get_divisor(n)
d2 = get_divisor(n - 1)
ans = -1
for i in d1:
    tmp = int(n)
    if i == 1:
        continue
    while tmp % i == 0:
        tmp //= i
    if tmp % i == 1:
        ans += 1
ans += len(d2)
print(ans)

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    lsls=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            lsls.append(i)
            if i!=n//i:
                lsls.append(n//i)
    lsls.sort()
    return lsls

N=int(input())

ans=1
for K in range(2,int(N**0.5)+2):
    num=N
    while num%K==0:
        num//=K
    if num>=K:
        num%=K
    if num==1:
        ans+=1

lst=make_divisors(N-1)

for u in lst:
    if u>=int(N**0.5)+2:
        ans+=1
        
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def divisors(n):
    div = [n]
    for i in xrange(2,int(math.sqrt(n))+1):
        if n%i == 0:
            div.append(i)
            div.append(n/i)
    return div

n = int(raw_input())
ndiv = set(divisors(n))
mdiv = set(divisors(n-1))
count = 0
for x in ndiv:
    for k in xrange(1,31):
        if x**k > n:
            break
        if (n%x**k)==0 and (n/x**k)%x == 1:
            count += 1
            #print x
            break
count += len(mdiv)
if n==2:
    count = 1
print count

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 1
for i in range(2, int(n**(1/2))+1):
  if (n-1)%i == 0:
    if n-1 == i**2:
      ans += 1
    else:
      ans += 2
  else:
    continue
for j in range(2, int(n**(1/2))+1):
  if n%j == 0:
    a = n
    while a%j == 0:
      a = a//j
    if (a-1)%j == 0:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 1
for i in range(2, int(n**(1/2))+1):
  if (n-1)%i == 0:
    if n-1 == i**2:
      ans += 1
    else:
      ans += 2
  else:
    continue
print(ans)
for j in range(2, int(n**(1/2))+1):
  if n%j == 0:
    a = n
    while a%j == 0:
      a = a//j
    if (a-1)%j == 0:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
import numpy as np
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

  if temp!=1:
    arr.append([temp, 1])

  if arr==[]:
    arr.append([n, 1])

  return arr

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
d=np.array(make_divisors(N))
soin=factorization(N)
#print(d)
#(K: 314132908543,  )
#割り切れて１になる。。。。Nの一通り
#Kで割ってK+1になった 約数の差が１
# M*(x-K)=K+1
#(x-K)%K==1
#(x-K)/K=M:::1
#x-K=M*K+1
#N-1の約数
#２は必ず入る
#素因数分解して素数一つならそれも
count=0


#print(make_divisors(N-1))
S=make_divisors(N-1)
#print(soin)
#１除くN加える
ans=len(S)-1+1
if 2 not in S:
  ans+=1
if len(soin)==1 and soin[0][0]!=N:
  for i in range(1,soin[0][1]+1):
    if soin[0][1]%i==0 and (soin[0][0])**i not in S and (soin[0][0])**i not in [2,N]:
      ans+=1
      #print((soin[0][0])**i)
  
print(ans)
#print(S)

Submission status: Wrong Answer

Solution code:
N=int(input())
import numpy as np
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

  if temp!=1:
    arr.append([temp, 1])

  if arr==[]:
    arr.append([n, 1])

  return arr

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
d=np.array(make_divisors(N))
soin=factorization(N)
#print(d)
#(K: 314132908543,  )
#割り切れて１になる。。。。Nの一通り
#Kで割ってK+1になった 約数の差が１
# M*(x-K)=K+1
#(x-K)%K==1
#(x-K)/K=M:::1
#x-K=M*K+1
#N-1の約数
#２は必ず入る
#素因数分解して素数一つならそれも
count=0


#print(make_divisors(N-1))
S=make_divisors(N-1)
#print(soin)
#１除く
ans=len(S)-1+1+1
if len(soin)==1 and soin[0][0]!=N:
  for i in range(1,soin[0][1]+1):
    if soin[0][1]%i==0 and (soin[0][0])**i not in S and (soin[0][0])**i not in [2,N]:
      ans+=1
      #print((soin[0][0])**i)
  
print(ans)
#print(S)

Submission status: Wrong Answer

Solution code:
N=int(input())
import numpy as np
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

  if temp!=1:
    arr.append([temp, 1])

  if arr==[]:
    arr.append([n, 1])

  return arr

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
d=np.array(make_divisors(N))
soin=factorization(N)
#print(d)
#(K: 314132908543,  )
#割り切れて１になる。。。。Nの一通り
#Kで割ってK+1になった 約数の差が１
# M*(x-K)=K+1
#(x-K)%K==1
#(x-K)/K=M:::1
#x-K=M*K+1
#N-1の約数
#２は必ず入る
#素因数分解して素数一つならそれも
count=0


#print(make_divisors(N-1))
S=make_divisors(N-1)
#print(soin)
#１除く
ans=len(S)-1+1+1
if len(soin)==1 and soin[0][0]!=N:
  for i in range(1,soin[0][1]+1):
    if soin[0][1]%i==0 and (soin[0][0])**i not in S:
      ans+=1
  
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
import numpy as np
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

  if temp!=1:
    arr.append([temp, 1])

  if arr==[]:
    arr.append([n, 1])

  return arr

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
d=np.array(make_divisors(N))
soin=factorization(N)
#print(d)
#(K: 314132908543,  )
#割り切れて１になる。。。。Nの一通り
#Kで割ってK+1になった 約数の差が１
# M*(x-K)=K+1
#(x-K)%K==1
#(x-K)/K=M:::1
#x-K=M*K+1
#N-1の約数
#２は必ず入る
#素因数分解して素数一つならそれも
count=0


#print(make_divisors(N-1))

#print(soin)
ans=len(make_divisors(N-1))-1+1+1
if len(soin)==1 and soin[0][0]!=N and soin[0][0] not in make_divisors(N-1):
  ans+=1
  
print(ans)