結果

問題 No.1006 Share an Integer
ユーザー konchanksukonchanksu
提出日時 2020-04-16 17:37:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 434 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 21:08:04
合計ジャッジ時間 4,994 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 30 ms
11,008 KB
testcase_03 AC 28 ms
11,008 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 28 ms
10,752 KB
testcase_06 AC 27 ms
10,880 KB
testcase_07 AC 27 ms
10,880 KB
testcase_08 AC 26 ms
11,008 KB
testcase_09 AC 27 ms
11,008 KB
testcase_10 AC 27 ms
10,752 KB
testcase_11 AC 239 ms
10,880 KB
testcase_12 AC 395 ms
10,880 KB
testcase_13 AC 428 ms
10,752 KB
testcase_14 AC 434 ms
10,752 KB
testcase_15 AC 362 ms
10,880 KB
testcase_16 AC 189 ms
10,880 KB
testcase_17 AC 260 ms
10,752 KB
testcase_18 AC 370 ms
10,752 KB
testcase_19 AC 357 ms
10,752 KB
testcase_20 AC 386 ms
10,880 KB
testcase_21 AC 423 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def yakusu(n):
    ans = 0
    for i in range(1, int(n ** (1 / 2)) + 1):
        if n % i == 0:
            if i != n ** (1 / 2):
                ans += 2
            else:
                ans += 1
    return ans

n = int(input())

ans = []
tmp = 10 ** 20
for i in range(n // 2 - int(n ** (1 / 2)), n // 2 + 1):
    if tmp > abs(i - yakusu(i) - ((n - i) - yakusu(n - i))):
        tmp = abs(i - yakusu(i) - ((n - i) - yakusu(n - i)))
        ans = [(i, n - i)] 
    elif tmp == abs(i - yakusu(i) - ((n - i) - yakusu(n - i))):
        ans += [(i, n - i)] 

for i in range(len(ans)):
    if ans[i][0] != 0:
        print(ans[i][0], ans[i][1])

for i in range(len(ans) - 1, -1, -1):
    if ans[i][0] != ans[i][1] and ans[i][0] != 0:
        print(ans[i][1], ans[i][0])
    
0