結果
| 問題 | 
                            No.864 四方演算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-02-16 01:49:00 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 67 ms / 1,000 ms | 
| コード長 | 665 bytes | 
| コンパイル時間 | 212 ms | 
| コンパイル使用メモリ | 82,688 KB | 
| 実行使用メモリ | 62,916 KB | 
| 最終ジャッジ日時 | 2024-07-23 17:20:51 | 
| 合計ジャッジ時間 | 3,033 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 | 
ソースコード
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
def check_pattern(n,p):
    if 2 <= p <= n+1:
        num = p-1
    elif n+2 <= p <= 2*n:
        num = 2*n+1-p
    else:
        num = 0
    return num
N,K = int(input()),int(input())
l = list(filter(lambda x: x <= 2*N, make_divisors(K)))
count = 0
for i in l:
    for j in l:
        if i*j == K:
            count += check_pattern(N,i)*check_pattern(N,j)
print(count)