結果

問題 No.1200 お菓子配り-3
ユーザー hir355hir355
提出日時 2020-08-28 22:18:37
言語 PyPy3
(7.3.13)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 833 bytes
コンパイル時間 411 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 78,208 KB
最終ジャッジ日時 2023-08-09 08:57:28
合計ジャッジ時間 24,624 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,704 KB
testcase_01 AC 78 ms
76,208 KB
testcase_02 AC 76 ms
75,760 KB
testcase_03 AC 74 ms
75,588 KB
testcase_04 AC 76 ms
75,720 KB
testcase_05 AC 76 ms
75,720 KB
testcase_06 AC 75 ms
75,904 KB
testcase_07 AC 93 ms
76,652 KB
testcase_08 AC 94 ms
76,656 KB
testcase_09 AC 90 ms
76,364 KB
testcase_10 AC 93 ms
76,484 KB
testcase_11 AC 91 ms
76,652 KB
testcase_12 AC 234 ms
77,616 KB
testcase_13 AC 234 ms
77,544 KB
testcase_14 AC 239 ms
77,512 KB
testcase_15 AC 239 ms
77,460 KB
testcase_16 AC 236 ms
77,628 KB
testcase_17 AC 618 ms
78,064 KB
testcase_18 AC 835 ms
78,184 KB
testcase_19 AC 265 ms
77,224 KB
testcase_20 AC 1,525 ms
78,156 KB
testcase_21 AC 1,522 ms
78,080 KB
testcase_22 AC 1,775 ms
78,084 KB
testcase_23 AC 1,533 ms
78,208 KB
testcase_24 AC 1,501 ms
77,860 KB
testcase_25 AC 1,514 ms
78,024 KB
testcase_26 AC 1,515 ms
78,136 KB
testcase_27 AC 67 ms
71,836 KB
testcase_28 AC 1,204 ms
77,980 KB
testcase_29 AC 3,247 ms
78,192 KB
testcase_30 AC 3,248 ms
77,980 KB
testcase_31 WA -
testcase_32 AC 68 ms
71,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def search_devisors(n):
    res = []
    for a in range(1, int(n ** .5) + 2):
        if n % a == 0:
            if a == n // a:
                res.append(a)
            else:
                res.append(a)
                res.append(n // a)
    res.sort()
    return res

input = sys.stdin.readline
s = int(input())
for _ in range(s):
    x, y = map(int, input().split())
    x, y = max(x, y), min(x, y)
    if x == y:
        d = search_devisors(x)
        print(x - 1 + len(d) - 2)
    else:
        d = search_devisors(x - y)
        ans = 0
        for k in d:
            t = (x - y) // k
            a = k + 1
            if (x - a * t) % (a + 1) == 0:
                c = (x - a * t) // (a + 1)
                b = t + c
                if c > 0 and y == a * c + b:
                    ans += 1
        print(ans)
0