結果

問題 No.864 四方演算
ユーザー stngstng
提出日時 2022-07-24 20:39:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 1,000 ms
コード長 705 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 76,264 KB
最終ジャッジ日時 2023-09-20 20:59:52
合計ジャッジ時間 4,283 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
72,000 KB
testcase_01 AC 86 ms
75,820 KB
testcase_02 AC 82 ms
75,688 KB
testcase_03 AC 85 ms
75,760 KB
testcase_04 AC 86 ms
75,976 KB
testcase_05 AC 81 ms
75,880 KB
testcase_06 AC 85 ms
75,820 KB
testcase_07 AC 83 ms
75,848 KB
testcase_08 AC 83 ms
75,872 KB
testcase_09 AC 78 ms
75,756 KB
testcase_10 AC 76 ms
75,856 KB
testcase_11 AC 76 ms
75,852 KB
testcase_12 AC 84 ms
75,772 KB
testcase_13 AC 80 ms
75,872 KB
testcase_14 AC 76 ms
75,620 KB
testcase_15 AC 88 ms
75,808 KB
testcase_16 AC 83 ms
75,588 KB
testcase_17 AC 84 ms
75,764 KB
testcase_18 AC 86 ms
76,264 KB
testcase_19 AC 80 ms
75,736 KB
testcase_20 AC 85 ms
75,936 KB
testcase_21 AC 85 ms
75,948 KB
testcase_22 AC 83 ms
75,760 KB
testcase_23 AC 74 ms
75,692 KB
testcase_24 AC 81 ms
75,596 KB
testcase_25 AC 77 ms
75,936 KB
testcase_26 AC 82 ms
75,684 KB
testcase_27 AC 70 ms
71,600 KB
testcase_28 AC 70 ms
71,680 KB
testcase_29 AC 70 ms
71,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
k = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

div = make_divisors(k)
ans = 0
for i in range((1+len(div))//2):
    ac,bd = div[i],div[len(div)-i-1]
    #print(ac,bd,ans)
    if ac > 2*n or bd > 2*n:
        continue
    if ac > n:
        acn = (n-(ac-n))+1
    else:
        acn = ac-1
    if bd > n:
        bdn = (n-(bd-n))+1
    else:
        bdn = bd-1
    #print(acn,bdn,"acbd",ac,bd)
    if ac == bd:
        ans += acn*bdn
    else:
        ans += acn*bdn*2

print(ans)
0