結果
問題 | No.2767 Add to Divide |
ユーザー | Butterflv |
提出日時 | 2024-05-31 21:46:23 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 554 bytes |
コンパイル時間 | 214 ms |
コンパイル使用メモリ | 82,524 KB |
実行使用メモリ | 69,024 KB |
最終ジャッジ日時 | 2024-05-31 21:46:36 |
合計ジャッジ時間 | 2,159 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
58,060 KB |
testcase_01 | AC | 44 ms
57,380 KB |
testcase_02 | AC | 40 ms
54,084 KB |
testcase_03 | AC | 90 ms
62,396 KB |
testcase_04 | AC | 41 ms
53,088 KB |
testcase_05 | AC | 72 ms
60,660 KB |
testcase_06 | AC | 74 ms
60,264 KB |
testcase_07 | AC | 73 ms
61,012 KB |
testcase_08 | AC | 96 ms
69,024 KB |
testcase_09 | AC | 80 ms
60,576 KB |
testcase_10 | AC | 87 ms
60,280 KB |
testcase_11 | AC | 81 ms
60,508 KB |
testcase_12 | AC | 81 ms
61,136 KB |
testcase_13 | AC | 79 ms
60,436 KB |
testcase_14 | AC | 82 ms
61,920 KB |
testcase_15 | AC | 78 ms
61,228 KB |
testcase_16 | AC | 78 ms
60,676 KB |
ソースコード
def make_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] T=int(input()) for _ in range(T): A,B=map(int,input().split()) if B-A==0: print(0) continue divi = make_divisors(B-A) MIN = 1<<60 for t in divi: X = ((B-A)//t) - A if X>=0: MIN = min(MIN, X) print(-1 if MIN==1<<60 else MIN)