Submission #11498195


Source Code Expand

Copy
#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(read())


def divisor(N):
    x = np.arange(1, 10 ** 6 + 1, dtype=np.int64)
    div = set(x[N % x == 0])
    return div | set(N // x for x in div)


cand = divisor(N) | divisor(N - 1)


def test(N, K):
    if K == 1:
        return False
    while N % K == 0:
        N //= K
    return N % K == 1


answer = sum(test(N, d) for d in cand)
print(answer)

Submission Info

Submission Time
Task F - Division or Subtraction
User maspy
Language Python (3.4.3)
Score 600
Code Size 548 Byte
Status AC
Exec Time 1972 ms
Memory 38324 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 25
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All hand_01, hand_02, hand_03, hand_04, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, random_11, random_12, random_13, random_14, random_15, random_16, random_17, random_18, sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
hand_01 AC 1972 ms 38324 KB
hand_02 AC 247 ms 29808 KB
hand_03 AC 189 ms 29040 KB
hand_04 AC 185 ms 29040 KB
random_01 AC 186 ms 29040 KB
random_02 AC 185 ms 28912 KB
random_03 AC 186 ms 29028 KB
random_04 AC 184 ms 28996 KB
random_05 AC 186 ms 28984 KB
random_06 AC 184 ms 29040 KB
random_07 AC 189 ms 29028 KB
random_08 AC 186 ms 29028 KB
random_09 AC 185 ms 29028 KB
random_10 AC 185 ms 29040 KB
random_11 AC 186 ms 29040 KB
random_12 AC 184 ms 29028 KB
random_13 AC 184 ms 28996 KB
random_14 AC 185 ms 28996 KB
random_15 AC 185 ms 29040 KB
random_16 AC 185 ms 29040 KB
random_17 AC 185 ms 28980 KB
random_18 AC 185 ms 29028 KB
sample_01 AC 185 ms 29040 KB
sample_02 AC 187 ms 29040 KB
sample_03 AC 183 ms 29040 KB