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:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############

N = inputI()

if N==2:
  print(1)
  exit()

dic = factorization(N)

P = [k for k in dic]

def Base_10_to_n(X, n):
  if (int(X/n)):
     return Base_10_to_n(int(X/n), n)+" "+str(X%n)
  return " "+str(X%n)

ans = 1
if P[0][0] > 1:
  for p,n in P:
    l = list(Base_10_to_n(N, p).strip(" 0"))
    if l[-1] == "1":
      ans += 1
else:
  ans = 1


dic = factorization(N-1)
P = [k for k in dic]

tempans = 1
for p,n in P:
  tempans *= n+1
ans += tempans-1

print(ans)

Submission status: Wrong Answer

Solution code:
def check(n, i):
    while n >= i and n % i == 0:
        n //= i
    return n % i == 1

def main():
    N = int(input())
    i = 2
    r = set()
    while i * i <= N:
        if N % i == 0:
            if check(N, i):
                r.add(i)
            if check(N, N // i):
                r.add(N // i)
        elif N % i == 1:
            r.add(i)
            if check(N, N // i):
                r.add(N // i)
        i += 1
    r.add(N - 1)
    r.add(N)
    return len(r)

print(main())

Submission status: Wrong Answer

Solution code:
N = int(input())
N_ = N-1
NL = [N]
N_L = [N_]
ans = 0

for i in range(2, int(N**(1/2))+1):
    if N % i == 0:
        NL.append(i)
        NL.append(N//i)
    if N_ % i == 0:
        N_L.append(i)
        N_L.append(N//i)
for a in N_L:
    if N % a == 1:
        ans += 1
for b in NL:
    n = N
    while (n >= b) and (n % b == 0):
        n = n // b
    if n >= b:
        if n % b == 1:
            ans += 1
    elif n == 1:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
N_ = N-1
NL = [N]
N_L = [N_]
ans = 0

for i in range(2, int(N**(1/2))+1):
    if N % i == 0:
        NL.append(i)
        NL.append(N//i)
    if N_ % i == 0:
        N_L.append(i)
        N_L.append(N//i)
for a in N_L:
    if N % a == 1:
        ans += 1
for b in NL:
    n = N
    while (n >= b) and (n % b == 0):
        n = n // b
    if n % b == 1:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
N_ = N-1
NL = [N]
N_L = [N_]
ans = 0

for i in range(2, int(N**(1/2))+1):
    if N % i == 0:
        NL.append(i)
        NL.append(N//i)
    if N_ % i == 0:
        N_L.append(i)
        N_L.append(N//i)
for a in N_L:
    if N % a == 1:
        ans += 1
for b in NL:
    n = N
    while n % b == 0:
        n = n // b
    if n % b == 1:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:

N = int(input())

def prime_cnt(N):
    # 約数列挙(1,N)も含まれる
    prime, i = set([2]), 1
    while i * i <= N:
        if N % i == 0:
            prime.add(i)
            prime.add(N//i)
        i += 1
    return prime
import math
ans = 0
p = prime_cnt(N-1)
if int(math.sqrt(N)) ** 2 == N:
    p.add(int(math.sqrt(N)))
print(len(p))

Submission status: Wrong Answer

Solution code:
def divisor(n):
  list1 = []
  for i in range(1, int(n ** (0.5)) + 1):
    if n % i == 0:
      list1.append(i)
      list1.append(int(n / i))
  list1 = list(set(list1))
  return len(list1) - 1

def function(n):
  ans = 0
  if n >= 2:
    ans += 1
  for i in range(2, int(n ** (0.5)) + 1):
    m = n
    if m % i == 0:
      while m % i == 0:
        m = int(m / i)
      ans += divisor(m)
  ans += divisor(n - 1)
  return ans
n = int(input())
print(function(n))

Submission status: Wrong Answer

Solution code:
def function(n):
  if n - 1 >= 2:
    ans = 2
  else:
    ans = 1
  for i in range(2, int(n ** (0.5)) + 1):
    m = n
    if m % i == 0:
      while m % i == 0:
        m = int(m / i)
      if m % i == 1:
        ans += 1
    elif m % i == 1:
      ans += 2
  return ans
n = int(input())
print(function(n))

Submission status: Wrong Answer

Solution code:
def function(n):
  ans = 2
  for i in range(2, int(n ** (0.5)) + 1):
    m = n
    if m % i == 0:
      while m % i == 0:
        m = int(m / i)
      if m % i == 1:
        ans += 1
    elif m % i == 1:
      ans += 2
  return ans
n = int(input())
print(function(n))

Submission status: Wrong Answer

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

def function(n):
  list1 = divisor(n - 1)
  ans = 1
  for i in range(2, int(n ** (0.5)) + 1):
    m = n
    if m % i == 0:
      while m % i == 0:
        m = int(m / i)
      if m % i == 1:
        ans += 1
  return ans + len(list1)
n = int(input())
print(function(n))

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 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 get_yakusu(n):
    ans = set()
    for i in range(1, int(math.sqrt(n)) + 2):
        if n % i == 0:
            if i != 1:
                ans.add(i)
            if n // i != i:
                ans.add(n // i)
    return ans

def main():
    N = I()
    cnt = 0
    yakusu = get_yakusu(N)
    n1yakusu = get_yakusu(N-1)
    for n in yakusu:
        cpN = N
        while cpN % n == 0 and cpN > n:
            cpN //= n
        if cpN % n == 1:
            cnt += 1
    cnt += len(n1yakusu)
    print(cnt)
main()

Submission status: Wrong Answer

Solution code:
num = int(input())
num -= 1
result = 1
for i in range(2, int(pow(num, 0.5))+1):
    c = 0
    while num%i==0:
        num //= i
        c += 1
    if c>0:
        result *= c+1

if num > 1:
    result *= 2
result -= 1
num += 1
for i in range(2, int(pow(num, 0.5))+1):
    n = num
    if n%i==0:
        while n%i==0:
            n //= i
        if n%i==1 or i%n==1:
            result += 1

print(result)

Submission status: Wrong Answer

Solution code:
num = int(input())
num -= 1
result = 1
for i in range(2, int(pow(num, 0.5))+1):
    c = 0
    while num%i==0:
        num //= i
        c += 1
    if c>0:
        result *= c+1

if num > 1:
    result *= 2
result -= 1
num += 1
for i in range(2, int(pow(num, 0.5))+1):
    n = num
    if n%i==0:
        while n%i==0:
            n //= i
        if n%i==1 or i%n==1:
            result += 1

print(result+1)

Submission status: Wrong Answer

Solution code:
num = int(input())
num -= 1
result = 1
for i in range(2, int(pow(num, 0.5))+1):
    c = 0
    while num%i==0:
        num //= i
        c += 1
    if c>0:
        result *= c+1
if num > 1:
    result *= 2
result += 1
print(result)

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)

    # divisors.sort()
    return divisors

N = int(input())
ans = 0
divs = make_divisors(N)
divs = [x for x in divs if x > 1]
for k in divs:
    x = N
    while k <= x:
        x //= k
    if x % k == 1:
        ans += 1

divs = make_divisors(N - 1)
divs = [x for x in divs if x > 1]
ans += len(divs)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()

    # naive, O(nlgn)
    # cnt = 0
    # for k in range(2, n + 1):
    #     tmp = n
    #     if tmp % k == 1:
    #         cnt += 1
    #     elif tmp % k == 0:
    #         while tmp >= k and tmp % k == 0:
    #             tmp //= k
    #         if tmp % k == 1:
    #             cnt += 1
    # print(cnt)

    class Eratos:
        def __init__(self, num):
            assert(num >= 1)
            self.table_max = num
            # self.table[i] は i が素数かどうかを示す (bool)
            self.table = [False if i == 0 or i == 1 else True for i in range(num+1)]
            for i in range(2, int(math.sqrt(num)) + 1):
                if self.table[i]:
                    for j in range(i ** 2, num + 1, i):    # i**2 からスタートすることで定数倍高速化できる
                        self.table[j] = False
            # self.table_max 以下の素数を列挙したリスト
            self.prime_numbers = [2] if self.table_max >= 2 else []
            for i in range(3, self.table_max + 1, 2):
                if self.table[i]:
                    self.prime_numbers.append(i)
        
        def is_prime(self, num):
            """
            >>> e = Eratos(100)
            >>> [i for i in range(1, 101) if e.is_prime(i)]
            [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
            """
            assert(num >= 1)
            if num > self.table_max:
                raise ValueError('Eratos.is_prime(): exceed table_max({}). got {}'.format(self.table_max, num))
            return self.table[num]
        
        def prime_factorize(self, num):
            """
            >>> e = Eratos(10000)
            >>> e.prime_factorize(6552)
            {2: 3, 3: 2, 7: 1, 13: 1}
            """
            assert(num >= 1)
            if int(math.sqrt(num)) > self.table_max:
                raise ValueError('Eratos.prime_factorize(): exceed prime table size. got {}'.format(num))
            factorized_dict = dict()    # 素因数分解の結果を記録する辞書
            candidate_prime_numbers = [i for i in range(2, int(math.sqrt(num)) + 1) if self.is_prime(i)]
            # n について、√n 以下の素数で割り続けると最後には 1 or 素数となる
            # 背理法を考えれば自明 (残された数が √n より上の素数の積であると仮定。これは自明に n を超えるため矛盾)
            for p in candidate_prime_numbers:
                # これ以上調査は無意味
                if num == 1:
                    break
                while num % p == 0:
                    num //= p
                    try:
                        factorized_dict[p]
                    except KeyError:
                        factorized_dict[p] = 0
                    finally:
                        factorized_dict[p] += 1
            if num != 1:
                factorized_dict[num] = 1
            return factorized_dict
    
    cnt = 0
    eratos = Eratos(int(math.sqrt(n)))
    cnt += 1    # k = n
    d = eratos.prime_factorize(n - 1)
    tmp = 1
    for _, v in d.items():
        tmp *= (v + 1)
    cnt += tmp    # n = k + 1, 2k + 1, 3k + 1, ...
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())

def yakusu(x):
    xx = 2
    y = []
    while xx**2 < x:
        if x%xx == 0:
            y.append(xx)
            y.append(x//xx)
        xx += 1
    if xx**2 == x:
        y.append(xx)
    y.append(x)
    return y

ans = len(yakusu(n-1))

for i in yakusu(n):
    nn = n
    while True:
        if nn%i == 0:
            nn = nn//i
        else:
            break
    if nn%i == 1:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

def yakusu(x):
    xx = 2
    y = []
    while xx*2 <= x:
        if x%xx == 0:
            y.append(xx)
        xx += 1
    y.append(x)
    return y

ans = len(yakusu(n-1))

for i in yakusu(n):
    nn = n
    while True:
        if nn%i == 0:
            nn = nn//i
        else:
            break
    if nn%i == 1:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

def yakusu(x):
    xx = 2
    y = []
    while xx*2 <= x:
        if x%xx == 0:
            y.append(xx)
        xx += 1
    return y

ans = len(yakusu(n-1))

kk = yakusu(n)
for i in kk:
    nn = n
    while True:
        if nn%i == 0:
            nn = nn//i
        else:
            break
    if nn%i == 1:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
ans=2

def go(n,k):
	aux=1
	while(n%k==0):
		n/=k
	if n%k==1:
		return True
	return False

for i in range(2,n):
	if(i*i>n): 
		break
	if n%i==0:
		if(go(n,i)): 
			ans+=1
		if(i!=n/i and go(n,n/i)):
			ans+=1
n-=1

for i in range(2,n):
	if(i*i>n): 
		break
	if n%i==0: 
		ans+=1
		if(i!=n/i):
			ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
ans=2

def go(n,k):
	aux=1
	while(aux<n):
		if (n-aux)%(aux*k)==0:
			return True
		aux*=k
	return False

for i in range(2,n):
	if(i*i>n): 
		break
	if n%i==0:
		if(go(n,i)): 
			ans+=1
		if(i!=n/i and go(n,n/i)):
			ans+=1
n-=1

for i in range(2,n):
	if(i*i>n): 
		break
	if n%i==0: 
		ans+=1
		if(i!=n/i):
			ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
ans=2

def go(n,k):
	aux=1
	while(aux<n):
		if (n-aux)%(aux*k)==0:
			return True
		aux*=k
	return False

for i in range(2,int( math.sqrt(n)  )+1):
	if n%i==0:
		if(go(n,i)): 
			ans+=1
		if(i!=n/i and go(n,n/i)):
			ans+=1
n-=1

for i in range(2,int(math.sqrt(n))+1):
	if n%i==0: 
		ans+=1
		if(i!=n/i):
			ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:

def main():
  n = int(input())

  def get_divisors(num):
    divisors = []
    for i in range(1, int(num ** 0.5) + 1):
      if num % i == 0:
        divisors.extend([i, num // i])

    return divisors

  ans = len(get_divisors(n - 1)) - 1

  for k in get_divisors(n)[1:]:
    num = n
    while num % k == 0:
      num = num // k

    if num % k == 1:
      ans += 1

  print(ans)

main()

Submission status: Wrong Answer

Solution code:
n = int(input())

# 例外処理
if n == 2:
    print(0)
    exit()
if n == 3:
    print(1)
    exit()

# n % k = 1 の数
m = n - 1
i = 2
ans = 1
while i * i <= m:
    if m % i == 0:
        num = 1
        while m % i == 0:
            num += 1
            m //= i
        ans *= num
    i = i + 1
if m != 1:
    ans *= 2
ans -= 1

# n % k = 0 の場合
# nを素因数分解する
m = n
import numpy as np
i = 2
factor = []
while i * i <= n:
    if n % i == 0:
        l = []
        num = 1
        l.append(num)
        while n % i == 0:
            num *= i
            l.append(num)
            n //= i
        factor.append(np.array(l))
    i = i + 1
if n > 1:
    factor.append(np.array([1, n]))

# 直積を求めることでnの全約数を得る
divisor = factor[-1]
for i in range(len(factor) - 1):
    divisor = np.outer(divisor, factor[i])
divisor = np.outer(np.array(1), divisor)

# 判定
for i in divisor[0]:
    if i == 1:
        continue
    n = m
    while n % i == 0:
        n //= i
    if n % i == 1:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
def calc_factors(N):
    """
    約数をlistでreturn
    この問題はK>1なので、約数に1を含めてない
    """
    i=2
    factors={N}
    while i*i<=N:
        if N%i==0:
            factors.add(i)
            factors.add(N//i)
        i+=1
    return list(sorted(factors))


N = int(input())

#割り算しない場合
ans = len(calc_factors(N-1))
#割り算する場合
for fac in calc_factors(N):
    tmp=N
    while tmp%fac==0:
        tmp//=fac
    if tmp%fac==1:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
n = int(input())

count = 0
floor1 = int((n-1)**0.5) + 1
floor2 = int(n**0.5) + 1
divisor2 = []

#Type1
for i in range(2,floor1):
    if (n - 1) % i == 0:
        count += 1
        if not i == (n - 1) // i:
            count += 1
count += 1

#divisor2 setting
for i in range(2,floor2):
    if n % i == 0:
        divisor2.append(i)
        if not i == n // i:
            divisor2.append(n // i)
divisor2.append(n)
divisor2.sort()

#Type2
for i in divisor2:
    m = n
    while m % i == 0:
        m = m // i
    if m % i == 1:
        count += 1

print('{}'.format(count))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

n = int(input())

count = 0
floor1 = int((n-1)**0.5) + 1
floor2 = int(n**0.5) + 1
divisor2 = []

#Type1
for i in range(2,floor1):
    if (n - 1) % i == 0:
        count += 1
        if not i == (n - 1) / i:
            count += 1
count += 1

#divisor2 setting
for i in range(2,floor2):
    if n % i == 0:
        divisor2.append(i)
        if not i == n / i:
            divisor2.append(n / i)
divisor2.append(n)

#Type2
for i in divisor2:
    m = n
    while m % i == 0:
        m = m // i
    if m % i == 1:
        count += 1

print('{}'.format(count))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

n = int(input())

count = 0
floor1 = int((n-1)**0.5) + 1
floor2 = int(n**0.5) + 1
divisor2 = []

#Type1
for i in range(2,floor1 + 1):
    if (n - 1) % i == 0:
        count += 1
        if not i == (n - 1) / i:
            count += 1
count += 1

#divisor2 setting
for i in range(2,floor2 + 1):
    if n % i == 0:
        divisor2.append(i)
        if not i == n / i:
            divisor2.append(n / i)
divisor2.append(n)

#Type2
for i in divisor2:
    m = n
    while m % i == 0:
        m = m // i
    if m % i == 1:
        count += 1

print('{}'.format(count))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

n = int(input())

count = 0
floor1 = math.floor((n-1) ** (1/2))
floor2 = math.floor(n ** (1/2))
divisor2 = []

#Type1
for i in range(2,floor1 + 1):
    if (n - 1) % i == 0:
        count += 1
        if not i == (n - 1) / i:
            count += 1
count += 1

#divisor2 setting
for i in range(2,floor2 + 1):
    if n % i == 0:
        divisor2.append(i)
        if not i == n / i:
            divisor2.append(n / i)
divisor2.append(n)

#Type2
for i in divisor2:
    m = n
    while m % i == 0:
        m = m // i
    if m % i == 1:
        count += 1

print('{}'.format(count))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

n = int(input())

count = 0
floor1 = math.floor((n-1) ** (1/2))
floor2 = math.floor(n ** (1/2))
divisor2 = []

#Type1
for i in range(2,floor1 + 1):
    if (n - 1) % i == 0:
        count += 1
        if not i == (n - 1) / i:
            count += 1
count += 1

#divisor2 setting
for i in range(2,floor2 + 1):
    if n % i == 0:
        divisor2.append(i)
        if not i == n / i:
            divisor2.append(n / i)
divisor2.append(n)

#Type2
for i in divisor2:
    m = n
    while m % i == 0:
        m = m / i
    if m % i == 1:
        count += 1

print('{}'.format(count))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import math

n = int(input())

count = 0
floor1 = math.floor((n-1) ** (1/2))
floor2 = math.floor(n ** (1/2))
divisor2 = []

#Type1
for i in range(2,floor1 + 1):
    if (n - 1) % i == 0:
        count += 2
count += 1

#divisor2 setting
for i in range(2,floor2 + 1):
    if n % i == 0:
        divisor2.append(i)
        divisor2.append(n / i)
divisor2.append(n)

#Type2
for i in divisor2:
    m = n
    while m % i == 0:
        m = m / i
    if m % i == 1:
        count += 1

print('{}'.format(count))

Submission status: Wrong Answer

Solution code:
N=int(input())
if N == 2:
    print(2)
    exit()
import math
sqrtN = math.ceil(N**0.5)
#print(sqrtN)

Dic = {}
N1 = N-1
for i in range(2,sqrtN+1):
    while N1 % i == 0:
        if i not in Dic:
            Dic[i] = 1
        else:
            Dic[i] += 1
        N1//=i
if N1>1:
    Dic[N1]=1
#print(Dic)
ANS=1
Flag=1
for k,v in Dic.items():
    ANS *= (v+1)
    if v%2 == 1:
        Flag = 0
print(ANS - Flag +1)

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)
    # divisors.sort()
    return divisors
num=int(input())
count=len(make_divisors(num-1))-1
num_divisors=make_divisors(num)
if len(num_divisors)!=2:
  count=count-1
for j in range(1,len(num_divisors)):
  while num%num_divisors[j]==0:
    num=num/num_divisors[j]
  if num%num_divisors[j]==1:
    count=count+1
print(count)

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)
    # divisors.sort()
    return divisors
num=int(input())
count=len(make_divisors(num-1))+1
if num<=5:
  count=count-1
num_divisors=make_divisors(num)
for j in range(1,len(num_divisors)):
  while num%num_divisors[j]==0:
    num=num/num_divisors[j]
  if num/num_divisors[j]==1:
    count=count+1
print(count)

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)
    # divisors.sort()
    return divisors
num=int(input())
count=len(make_divisors(num-1))+1
if num<=3:
  count=count-1
num_divisors=make_divisors(num)
for j in range(1,len(num_divisors)):
  while num%num_divisors[j]==0:
    num=num/num_divisors[j]
  if num/num_divisors[j]==1:
    count=count+1
print(count)

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)
    # divisors.sort()
    return divisors
num=int(input())
count=len(make_divisors(num-1))+1
if num==2:
  count=count-1
num_divisors=make_divisors(num)
for j in range(1,len(num_divisors)):
  while num%num_divisors[j]==0:
    num=num/num_divisors[j]
  if num/num_divisors[j]==1:
    count=count+1
print(count)

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)
    # divisors.sort()
    return divisors
num=int(input())
count=len(make_divisors(num-1))+1
num_divisors=make_divisors(num)
for j in range(1,len(num_divisors)):
  while num%num_divisors[j]==0:
    num=num/num_divisors[j]
  if num/num_divisors[j]==1:
    count=count+1
print(count)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())

    # K > 1

    def divisor_set(x):
        ret = {x}
        d = 2
        while d * d <= x:
            if x % d == 0:
                ret.add(d)
                ret.add(x // d)
            d += 1
        return ret

    # N % K == 1
    # (N-1) % K == 0
    # K > 1

    ans = 0
    ans += len(divisor_set(N - 1))

    # N % K == 0
    # N //= K ---> M
    # (M-1) % K == 0

    for k in divisor_set(N):
        x = N
        while x % k == 0:
            x //= k
        if x % k == 1:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Wrong Answer

Solution code:
def divisors(n):
    ret = set()
    for i in range(1, int(n**0.5)+2):
        if n % i == 0:
            if i != 1:
                ret.add(i)
            ret.add(n // i)
    return ret


def main():
    N = int(input())
    s = divisors(N)
    ans = divisors(N-1)

    for x in s:
        n = N
        if x == 1:
            continue
        while(n % x == 0):
            n = n // x
        if n % x == 1:
            ans.add(x)
    print(len(ans))


main()

Submission status: Wrong Answer

Solution code:
def divisors(n):
    ret = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i != 1:
                ret.add(i)
            ret.add(n // i)
    return ret


def main():
    N = int(input())
    s = divisors(N)
    ans = divisors(N-1)

    for x in s:
        n = N
        if x == 1:
            continue
        while(n % x == 0):
            n = n // x
        if n % x == 1:
            ans.add(x)
    print(len(ans))


main()

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    def divisor(n):
        ass = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                ass.append(i)
                if i ** 2 == n:
                    continue
                ass.append(n // i)
        return ass  # sortされていない
    g = sorted(divisor(n))
    q = []
    for i in range(1, len(g)):
        m=n
        while (m % g[i]) == 0 and m > g[i]:
            if m %g[i] == 0:
                m = m//g[i]
            else:
                m = m%g[i]
        if m == 1:
            q.append(g[i])
    print(len(set(divisor(n-1)+q))+1)

resolve()

Submission status: Wrong Answer

Solution code:
def divisors(n):
    ret = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i != 1:
                ret.add(i)
            ret.add(n // i)
    return ret
def main():
    N = int(input())
    s = divisors(N)
    ans = divisors(N-1)

    for x in s:
        n = N
        while(n % x == 0):
            n = n // x
        if n % x == 1:
            ans.add(x)
    print(len(ans))
main()

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    def divisor(n):
        ass = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                ass.append(i)
                if i ** 2 == n:
                    continue
                ass.append(n // i)
        return ass  # sortされていない
    p = len(divisor(n-1))
    g = sorted(divisor(n))
    q = 0
    for i in range(len(g)):
        while (n % g[i]) != 0 and n < g[i]:
            if n %g[i] == 0:
                n = n//g[i]
            else:
                n = n%g[i]
        if n == 1:
            q += 1
    print(p+q+1)

resolve()