結果

問題 No.826 連絡網
コンテスト
ユーザー ttr
提出日時 2020-02-26 16:49:30
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 622 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 475 ms
コンパイル使用メモリ 20,828 KB
実行使用メモリ 27,224 KB
最終ジャッジ日時 2026-05-01 02:07:01
合計ジャッジ時間 6,146 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,P = map(int, input().split())

def gcd(a, b):
    if a < b:
        a, b = b, a
    if a%b == 0:
        return b
    return gcd(b, a%b)

if P > 1:
    L = [0]*(N+1)
    n = 2
    num = P
    while n <= P**0.5:
        if P%n == 0:
            num = n
            break
        n += 1
    if num*2 <= N:
        ans = 0
        for i in range(2, N+1):
            if i*2 <= N:
                ans += 1
                continue
            n = 2
            while n <= i**0.5:
                if i%n == 0:
                    ans += 1
                    break
                n += 1
    else:
        ans = 1

print(ans)
0