結果

問題 No.800 四平方定理
ユーザー tempura_pptempura_pp
提出日時 2019-03-15 16:17:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,530 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 70,728 KB
最終ジャッジ日時 2023-09-14 12:27:48
合計ジャッジ時間 23,186 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
70,404 KB
testcase_01 AC 72 ms
70,440 KB
testcase_02 AC 66 ms
70,348 KB
testcase_03 AC 68 ms
70,428 KB
testcase_04 AC 66 ms
70,388 KB
testcase_05 AC 67 ms
70,652 KB
testcase_06 AC 79 ms
70,384 KB
testcase_07 AC 76 ms
70,728 KB
testcase_08 AC 83 ms
70,620 KB
testcase_09 AC 73 ms
70,536 KB
testcase_10 AC 799 ms
70,488 KB
testcase_11 AC 837 ms
70,588 KB
testcase_12 AC 876 ms
70,436 KB
testcase_13 AC 725 ms
70,344 KB
testcase_14 AC 767 ms
70,344 KB
testcase_15 AC 878 ms
70,400 KB
testcase_16 AC 787 ms
70,460 KB
testcase_17 AC 777 ms
70,552 KB
testcase_18 AC 950 ms
70,552 KB
testcase_19 AC 949 ms
70,612 KB
testcase_20 AC 52 ms
70,580 KB
testcase_21 AC 52 ms
70,680 KB
testcase_22 AC 948 ms
70,636 KB
testcase_23 AC 1,525 ms
70,392 KB
testcase_24 AC 1,339 ms
70,448 KB
testcase_25 AC 1,530 ms
70,532 KB
testcase_26 AC 53 ms
70,436 KB
testcase_27 AC 52 ms
70,684 KB
testcase_28 AC 1,334 ms
70,604 KB
testcase_29 AC 1,459 ms
70,444 KB
testcase_30 AC 1,332 ms
70,444 KB
testcase_31 AC 1,247 ms
70,424 KB
testcase_32 AC 1,369 ms
70,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n,d=map(int,input().split())
    MAX=8000001
    cnt=[0]*MAX
    cnt[d]=2*n
    for i in range(1,n+1) :
        for j in range(i+1,n+1) :
            cnt[j*j-i*i+d]+=2
            if i*i-j*j+d>0 :
                cnt[i*i-j*j+d]+=2
    ans=0
    for i in range(1,n+1) :
        for j in range(i+1,n+1) :
            if(i*i+j*j<=5000000):
                ans+=cnt[i*i+j*j]
    for i in range(1,n+1) :
        ans+=cnt[2*i*i]//2
    print(ans)
solve()
0