結果

問題 No.1006 Share an Integer
ユーザー KodaiKodai
提出日時 2020-04-16 16:49:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 929 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 17,948 KB
最終ジャッジ日時 2024-04-09 20:00:11
合計ジャッジ時間 4,207 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
17,824 KB
testcase_01 AC 28 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 WA -
testcase_04 AC 32 ms
10,880 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 30 ms
11,008 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 29 ms
10,880 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 f(x):
    temp = x
    count_dict = {}
    while True:
        if x == 1:
            break
        for i in range(2, x+1):
            if x % i == 0:
                if i not in count_dict:
                    count_dict[i] = 1
                else:
                    count_dict[i] += 1
                x //= i
                break
    count = 1
    for i in count_dict.values():
        count *= (i+1)
    return temp-count


def difference(x, y):
    return abs(f(x)-f(y))


X = int(input())

temp_dict = {}
for i in range(1, X//2+1):
    if abs(i-(X-i)) <= 2*(2*math.sqrt(X)+1):
        diff = difference(i, X-i)
        if diff not in temp_dict:
            temp_dict[diff] = [[i, X-i]]
        else:
            temp_dict[diff].append([i, X-i])

min_key = min(temp_dict.keys())
for data in temp_dict[min_key]:
    print(data[0], data[1])
for data in temp_dict[min_key][::-1]:
    print(data[1], data[0])
0