結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,724 KB
testcase_01 AC 87 ms
75,796 KB
testcase_02 AC 83 ms
75,692 KB
testcase_03 AC 90 ms
76,132 KB
testcase_04 AC 87 ms
75,584 KB
testcase_05 AC 83 ms
75,608 KB
testcase_06 AC 86 ms
75,804 KB
testcase_07 AC 86 ms
75,616 KB
testcase_08 AC 84 ms
75,780 KB
testcase_09 AC 80 ms
75,720 KB
testcase_10 AC 81 ms
75,804 KB
testcase_11 AC 78 ms
75,544 KB
testcase_12 AC 83 ms
75,620 KB
testcase_13 AC 80 ms
75,712 KB
testcase_14 AC 78 ms
75,680 KB
testcase_15 AC 89 ms
75,932 KB
testcase_16 AC 86 ms
75,928 KB
testcase_17 AC 87 ms
75,852 KB
testcase_18 AC 87 ms
76,144 KB
testcase_19 AC 83 ms
75,804 KB
testcase_20 AC 87 ms
75,680 KB
testcase_21 AC 87 ms
75,616 KB
testcase_22 AC 84 ms
75,616 KB
testcase_23 AC 77 ms
75,676 KB
testcase_24 AC 85 ms
75,848 KB
testcase_25 AC 80 ms
75,676 KB
testcase_26 AC 84 ms
75,800 KB
testcase_27 AC 72 ms
71,800 KB
testcase_28 AC 73 ms
71,868 KB
testcase_29 AC 73 ms
71,640 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