結果

問題 No.800 四平方定理
ユーザー tempura_pptempura_pp
提出日時 2019-03-15 16:00:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,386 ms / 2,000 ms
コード長 426 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 11,012 KB
実行使用メモリ 70,772 KB
最終ジャッジ日時 2023-09-14 12:22:00
合計ジャッジ時間 20,464 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
70,436 KB
testcase_01 AC 69 ms
70,512 KB
testcase_02 AC 62 ms
70,660 KB
testcase_03 AC 63 ms
70,404 KB
testcase_04 AC 62 ms
70,512 KB
testcase_05 AC 64 ms
70,772 KB
testcase_06 AC 70 ms
70,592 KB
testcase_07 AC 71 ms
70,484 KB
testcase_08 AC 78 ms
70,444 KB
testcase_09 AC 66 ms
70,460 KB
testcase_10 AC 691 ms
70,620 KB
testcase_11 AC 716 ms
70,428 KB
testcase_12 AC 768 ms
70,436 KB
testcase_13 AC 625 ms
70,528 KB
testcase_14 AC 681 ms
70,496 KB
testcase_15 AC 772 ms
70,504 KB
testcase_16 AC 675 ms
70,500 KB
testcase_17 AC 677 ms
70,640 KB
testcase_18 AC 844 ms
70,632 KB
testcase_19 AC 835 ms
70,508 KB
testcase_20 AC 53 ms
70,592 KB
testcase_21 AC 52 ms
70,428 KB
testcase_22 AC 839 ms
70,572 KB
testcase_23 AC 1,385 ms
70,416 KB
testcase_24 AC 1,189 ms
70,540 KB
testcase_25 AC 1,386 ms
70,396 KB
testcase_26 AC 52 ms
70,624 KB
testcase_27 AC 52 ms
70,388 KB
testcase_28 AC 1,185 ms
70,528 KB
testcase_29 AC 1,294 ms
70,572 KB
testcase_30 AC 1,184 ms
70,440 KB
testcase_31 AC 1,102 ms
70,488 KB
testcase_32 AC 1,229 ms
70,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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