結果

問題 No.1006 Share an Integer
ユーザー takakintakakin
提出日時 2020-06-09 23:06:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 508 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 11,020 KB
実行使用メモリ 8,000 KB
最終ジャッジ日時 2023-08-31 01:32:47
合計ジャッジ時間 2,188 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,824 KB
testcase_01 AC 15 ms
7,952 KB
testcase_02 AC 17 ms
7,796 KB
testcase_03 WA -
testcase_04 AC 17 ms
7,812 KB
testcase_05 AC 17 ms
7,824 KB
testcase_06 AC 17 ms
7,852 KB
testcase_07 AC 17 ms
7,800 KB
testcase_08 AC 17 ms
7,880 KB
testcase_09 AC 17 ms
7,944 KB
testcase_10 AC 17 ms
7,804 KB
testcase_11 AC 34 ms
7,816 KB
testcase_12 AC 41 ms
8,000 KB
testcase_13 AC 41 ms
7,792 KB
testcase_14 AC 40 ms
7,852 KB
testcase_15 AC 39 ms
7,876 KB
testcase_16 AC 31 ms
7,796 KB
testcase_17 AC 35 ms
7,888 KB
testcase_18 AC 40 ms
7,792 KB
testcase_19 AC 38 ms
7,832 KB
testcase_20 AC 40 ms
7,812 KB
testcase_21 AC 41 ms
7,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())

def ct(n):
  ret=0
  for i in range(1,int(n**0.5)+1):
    if n%i==0:
      ret+=1
      if i!=n//i:
        ret+=1
  return ret

w=200
D=dict()
for i in range(max(1,n//2-w),min(n-1,n//2+w)):
  D[i]=i-ct(i)
ans=float("inf")
for d in D.keys():
  if n-d in D.keys():
    ans=min(ans,abs(D[d]-D[n-d]))
Ans=[]
for d in D.keys():
  if n-d in D.keys() and abs(D[d]-D[n-d])==ans:
    Ans.append((d,n-d))
Ans.sort()
for a,b in Ans:
  print(a,b)

0