結果
| 問題 | 
                            No.826 連絡網
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ゆるく
                         | 
                    
| 提出日時 | 2019-05-03 22:53:37 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 865 bytes | 
| コンパイル時間 | 361 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 27,648 KB | 
| 最終ジャッジ日時 | 2024-12-31 18:54:35 | 
| 合計ジャッジ時間 | 4,828 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | WA * 30 | 
ソースコード
# 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 *
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
n, p = map(int, input().split())
table = prime_table(n)
if is_prime(p):
    print(1)
else:
    print(n - sum(table) + 1)
            
            
            
        
            
ゆるく