結果

問題 No.719 Coprime
ユーザー daku9640daku9640
提出日時 2018-07-28 02:57:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 940 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 19,376 KB
最終ジャッジ日時 2023-09-19 05:53:57
合計ジャッジ時間 12,518 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
19,376 KB
testcase_01 AC 22 ms
8,720 KB
testcase_02 AC 21 ms
8,668 KB
testcase_03 AC 22 ms
8,804 KB
testcase_04 AC 22 ms
8,692 KB
testcase_05 AC 21 ms
8,752 KB
testcase_06 AC 21 ms
8,724 KB
testcase_07 AC 21 ms
8,744 KB
testcase_08 AC 22 ms
8,752 KB
testcase_09 AC 22 ms
8,752 KB
testcase_10 AC 21 ms
8,676 KB
testcase_11 AC 22 ms
8,820 KB
testcase_12 AC 22 ms
8,836 KB
testcase_13 AC 22 ms
8,772 KB
testcase_14 AC 21 ms
8,836 KB
testcase_15 AC 21 ms
8,684 KB
testcase_16 AC 21 ms
8,788 KB
testcase_17 AC 21 ms
8,764 KB
testcase_18 AC 22 ms
8,696 KB
testcase_19 AC 22 ms
8,692 KB
testcase_20 AC 22 ms
8,764 KB
testcase_21 AC 21 ms
8,700 KB
testcase_22 AC 21 ms
8,836 KB
testcase_23 AC 22 ms
8,728 KB
testcase_24 AC 22 ms
8,708 KB
testcase_25 AC 23 ms
8,876 KB
testcase_26 AC 22 ms
8,604 KB
testcase_27 AC 22 ms
8,780 KB
testcase_28 AC 22 ms
8,768 KB
testcase_29 AC 22 ms
8,848 KB
testcase_30 AC 21 ms
8,740 KB
testcase_31 AC 22 ms
8,700 KB
testcase_32 AC 22 ms
8,740 KB
testcase_33 AC 22 ms
8,932 KB
testcase_34 AC 22 ms
8,852 KB
testcase_35 AC 22 ms
8,888 KB
testcase_36 AC 23 ms
8,740 KB
testcase_37 AC 22 ms
8,900 KB
testcase_38 AC 23 ms
8,848 KB
testcase_39 AC 23 ms
8,720 KB
testcase_40 AC 23 ms
8,768 KB
testcase_41 AC 27 ms
8,768 KB
testcase_42 AC 31 ms
8,920 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 TLE -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(200000)
from collections import defaultdict
from itertools import product
from copy import deepcopy, copy
n = int(input())
so = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31)
sn = set(range(2, n + 1))
sc = set()
sm = defaultdict(set)
for i in range(2, n + 1):
    for a in (b for b in so if b <= i and b * 2 <= n):
        if i % a == 0:
            sm[a].add(i)
            sc.add(i)
for v in list(sm.values()):
    v = list(v)
    for b, c in product(list(v), repeat=2):
        sm[b].add(c)
    if len(sm[v[0]]) == 1:
        sc.add(v[0])
        sn.remove(v[0])
        continue
ans = 0
def f(a, n, st, cnt):
    if len(st) == 0 or a > n:
        global ans
        ans = max(ans, cnt)
        return
    if sm[so[a]] & st:
        for b in sm[so[a]] & st:
            f(a + 1, n, st - sm[b], cnt + b)
    else:
        f(a + 1, n, st, cnt)
f(0, sum(1 for b in so if b <= n), sc, 0)
print(ans + sum(sn - sc))
0