結果

問題 No.826 連絡網
ユーザー ゆるくゆるく
提出日時 2019-05-03 22:41:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 858 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 10,780 KB
実行使用メモリ 26,244 KB
最終ジャッジ日時 2023-08-30 06:15:46
合計ジャッジ時間 4,962 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,340 KB
testcase_01 AC 31 ms
10,288 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, p = map(int, input().split())

def is_prime(n):
    i = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += 1
    return True
def prime_table(n):
    list = [True for _ in range(n + 1)]
    i = 2
    while i * i <= n:
        if list[i]:
            j = i + i
        while j <= n:
            list[j] = False
            j += i
        i += 1
    table = []
    for i in range(n + 1):
        if list[i] and i >= 2:
            table.append(1)
        else:
            table.append(0)
    return table
table = prime_table(n)

if is_prime(p):
    print(1)
else:
    print(n - sum(table[0:n]) + 1)
0