結果

問題 No.1200 お菓子配り-3
ユーザー marroncastlemarroncastle
提出日時 2020-08-28 22:06:15
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 688 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 76,544 KB
最終ジャッジ日時 2024-04-26 23:08:13
合計ジャッジ時間 23,777 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,968 KB
testcase_01 AC 43 ms
57,216 KB
testcase_02 AC 46 ms
56,960 KB
testcase_03 AC 46 ms
57,088 KB
testcase_04 AC 46 ms
56,960 KB
testcase_05 AC 47 ms
56,960 KB
testcase_06 AC 46 ms
57,728 KB
testcase_07 AC 64 ms
58,624 KB
testcase_08 AC 63 ms
58,496 KB
testcase_09 AC 63 ms
58,880 KB
testcase_10 AC 62 ms
58,368 KB
testcase_11 AC 60 ms
58,752 KB
testcase_12 AC 217 ms
69,632 KB
testcase_13 AC 221 ms
71,040 KB
testcase_14 AC 220 ms
69,248 KB
testcase_15 AC 223 ms
68,992 KB
testcase_16 AC 219 ms
69,760 KB
testcase_17 AC 618 ms
76,544 KB
testcase_18 AC 859 ms
76,544 KB
testcase_19 AC 252 ms
70,016 KB
testcase_20 AC 1,544 ms
76,288 KB
testcase_21 AC 1,538 ms
76,288 KB
testcase_22 AC 1,794 ms
76,544 KB
testcase_23 AC 1,543 ms
76,288 KB
testcase_24 AC 1,523 ms
76,544 KB
testcase_25 AC 1,533 ms
76,288 KB
testcase_26 AC 1,536 ms
76,416 KB
testcase_27 AC 40 ms
52,352 KB
testcase_28 AC 1,204 ms
76,160 KB
testcase_29 AC 3,260 ms
76,032 KB
testcase_30 AC 3,252 ms
76,288 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisor(n):
  cd = []
  i = 1
  while i*i <= n:
    if n%i==0:
      cd.append(i)
    i += 1
  return cd

def check(bpc,bmc):
  if (bpc+bmc)%2==1:
    return False
  if bpc-bmc<=0:
    return False
  return True

def solve():
  S = int(input())
  ans = [0]*S
  for s in range(S):
    X, Y = map(int, input().split())
    d = abs(X-Y)
    xy = X+Y
    divs = divisor(d)
    for div in divs:
      div2 = d//div
      if xy%(div+2)==0:
        bpc = xy//(div+2)
        bmc = div2
        if check(bpc,bmc):
          ans[s] += 1
      if xy%(div2+2)==0:
        bpc = xy//(div2+2)
        bmc = div
        if check(bpc,bmc):
          ans[s] += 1
  return ans
print(*solve(),sep='\n')
0