結果

問題 No.800 四平方定理
ユーザー buey_t
提出日時 2023-03-23 12:01:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,576 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 246,180 KB
最終ジャッジ日時 2024-09-18 15:25:05
合計ジャッジ時間 13,250 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    
    
    '''
    2乗までは回る
    x^2+y^2 = (w+z)(w-z)+D
    
    2*4
    w = 3,z = 1
    
    3*5
    w = 4,z = 1
    
    5*10
    ない
    
    5*11
    w = 8, z = 3
    
    7*4
    ない
    
    差が偶数ならよい?
    '''
    
    
    N,D = map(int, input().split())
    
    left = [0]*(10**7)
    right = [0]*(10**7)
    
    for i in range(1,N+1):
        for j in range(1,N+1):
            left[i**2+j**2] += 1
    
    for i in range(1,N+1):
        for j in range(1,N+1):
            right[i**2-j**2+D] += 1
    
    ans = 0
    for i in range(10**7):
        ans += left[i]*right[i]
    
    print(ans)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0