結果
| 問題 |
No.1006 Share an Integer
|
| コンテスト | |
| ユーザー |
FromBooska
|
| 提出日時 | 2023-09-24 08:33:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,032 bytes |
| コンパイル時間 | 162 ms |
| コンパイル使用メモリ | 82,212 KB |
| 実行使用メモリ | 91,416 KB |
| 最終ジャッジ日時 | 2024-07-17 08:57:50 |
| 合計ジャッジ時間 | 4,308 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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
if i > j:
break
calc = abs(i-count[i]-j+count[j])
#print('i', i, 'j', j, 'calc', calc)
if calc < mn:
mn = calc
if i != j:
ans_list = [(i, j), (j, i)]
else:
ans_list = [(i, j)]
elif calc == mn:
if i != j:
ans_list.append((i, j))
ans_list.append((j, i))
else:
ans_list.append((i, j))
ans_list.sort()
#print(mn)
#print(ans_list)
for i, j in ans_list:
print(i, j)
FromBooska