結果
問題 | No.1006 Share an Integer |
ユーザー |
![]() |
提出日時 | 2023-09-24 08:29:49 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 807 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 91,644 KB |
最終ジャッジ日時 | 2024-07-17 08:53:50 |
合計ジャッジ時間 | 4,754 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 TLE * 1 -- * 10 |
ソースコード
# X<2*10**6と小さいので全探索して間に合うのでは X = int(input()) count = [0]*(X+1) def divisors(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] for x in range(1, X+1): calc = len(divisors(x)) count[x] = calc ans_list = [] mn = 10**10 for i in range(1, X): j = X-i calc = abs(i-count[i]-j+count[j]) #print('i', i, 'j', j, 'calc', calc) if calc < mn: mn = calc ans_list = [(i, j)] elif calc == mn: ans_list.append((i, j)) #print(mn) #print(ans_list) for i, j in ans_list: print(i, j)