結果

問題 No.1006 Share an Integer
ユーザー kbyskbys
提出日時 2020-06-23 23:40:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 682 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 78,060 KB
最終ジャッジ日時 2023-09-16 20:20:47
合計ジャッジ時間 8,955 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
29,788 KB
testcase_01 AC 120 ms
29,596 KB
testcase_02 AC 122 ms
29,700 KB
testcase_03 WA -
testcase_04 AC 122 ms
29,612 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 123 ms
29,776 KB
testcase_09 AC 122 ms
29,688 KB
testcase_10 AC 120 ms
29,656 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
import numpy as np

X = int(input())

#それぞれの約数の個数
yakusu = np.array([2]*(X+1))
yakusu[0] = 0
yakusu[1] = 1

for i in range(2,X//2+1):
    yakusu[2*i::i] += 1
    
fn = np.array([0]*(X+1))
for i in range(1,X+1):
    fn[i] = i - yakusu[i]
    
#print(yakusu[1:X+1])
#print(fn[1:X+1])

minimum = float('inf')
for u in range(1,X//2+1):
    v = X-u
    tmp = abs(fn[u]-fn[v])
    #print(u,v,tmp)
    if tmp < minimum:
        ans = {}
        ans[tmp] = [(u,v)]
        minimum = tmp
    elif tmp == minimum:
        ans[tmp].append((u,v))

for r in ans[minimum]:
    u, v = r
    print(u, v)

for r in ans[minimum][::-1]:
    u, v = r
    print(v,u)
0