結果
問題 | No.1200 お菓子配り-3 |
ユーザー | chielo |
提出日時 | 2020-08-28 22:40:05 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,557 bytes |
コンパイル時間 | 460 ms |
コンパイル使用メモリ | 81,860 KB |
実行使用メモリ | 83,708 KB |
最終ジャッジ日時 | 2024-04-26 23:56:48 |
合計ジャッジ時間 | 22,847 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,652 KB |
testcase_01 | AC | 45 ms
58,704 KB |
testcase_02 | AC | 49 ms
59,144 KB |
testcase_03 | AC | 48 ms
58,512 KB |
testcase_04 | AC | 49 ms
59,260 KB |
testcase_05 | AC | 50 ms
59,436 KB |
testcase_06 | AC | 47 ms
59,856 KB |
testcase_07 | AC | 98 ms
62,848 KB |
testcase_08 | AC | 101 ms
63,572 KB |
testcase_09 | AC | 97 ms
62,792 KB |
testcase_10 | AC | 97 ms
62,920 KB |
testcase_11 | AC | 99 ms
62,588 KB |
testcase_12 | AC | 515 ms
76,456 KB |
testcase_13 | AC | 515 ms
74,252 KB |
testcase_14 | AC | 529 ms
75,976 KB |
testcase_15 | AC | 523 ms
75,964 KB |
testcase_16 | AC | 516 ms
74,324 KB |
testcase_17 | AC | 1,669 ms
76,764 KB |
testcase_18 | AC | 2,357 ms
76,424 KB |
testcase_19 | AC | 606 ms
75,900 KB |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
def subsolve(x): ans = 0 for i in range(1, x): if i * i > x: break if x % i: continue if x // i - 1 > 0: ans += 1 if x != i * i and x // (x // i) - 1 > 0: ans += 1 ans += x print(ans) def solve(): x, y = map(int, input().split()) if x == y: subsolve(x) return if x < y: x, y = y, x ans = 0 su, sv, tu, tv = [], [], [], [] for a in range(1, x + y): if a * a > x + y: break if (x + y) % a: continue su.append(a - 1) if (x + y) // a != a: sv.append((x + y) // a - 1) for a in range(1, x - y): if a * a > x - y: break if (x - y) % a: continue tu.append(a + 1) if (x - y) // a != a: tv.append((x - y) // a + 1) sv.reverse() s = su s.extend(sv) tv.reverse() t = tu t.extend(tv) i, j = 0, 0 ans = 0 while i < len(s) and j < len(t): if s[i] != t[j]: if s[i] < t[j]: i += 1 else: j += 1 else: a = s[i] if a - 1 > 0: bpc = (x + y) // (a + 1) bmc = (x - y) // (a - 1) b = (bpc + bmc) // 2 c = x - a * b if b > 0 and c > 0 and a * c + b == y: ans += 1 i += 1 j += 1 print(ans) t = int(input()) for _ in range(t): solve()