結果

問題 No.1006 Share an Integer
ユーザー konchanksukonchanksu
提出日時 2020-03-06 23:25:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 948 bytes
コンパイル時間 348 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 18,076 KB
最終ジャッジ日時 2024-04-22 10:37:45
合計ジャッジ時間 4,438 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
18,076 KB
testcase_01 AC 36 ms
11,008 KB
testcase_02 AC 40 ms
11,008 KB
testcase_03 WA -
testcase_04 AC 43 ms
11,136 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 52 ms
11,136 KB
testcase_09 AC 65 ms
11,008 KB
testcase_10 AC 59 ms
11,136 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def soinsu(lists, num):
    for i in range(2, int(math.sqrt(num)) + 1):
        if num % i == 0:
            lists.append(i)
            return soinsu(lists, num / i)
    
    lists.append(int(num))
    lists.append(1)
    return lists

def tindon(lists, num=1, sets=set(), longer=0):
    for i in range(2):
        num *= (lists[longer] ** i)
        if longer != len(lists) - 1:
            tindon(lists, num, sets, longer + 1)
        else:
            sets.add(num)

    return len(sets)
        
x = int(input())
ans, big = [], x

for i in range(1, x // 2 + 1):    
    a = i - tindon(soinsu([], i), sets=set())
    b = x - i - tindon(soinsu([], x-i), sets=set())

    if abs(a - b) == big:
        big = abs(a - b)
        ans.append(i)
        ans.append(x - i)
    elif abs(a - b) < big:
        ans.clear()
        ans.append(i)
        ans.append(x - i)
        big = abs(a - b)

ans.sort()

for i in ans:
    print(i, x - i)
0