結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
70,596 KB
testcase_01 AC 72 ms
70,484 KB
testcase_02 AC 65 ms
70,584 KB
testcase_03 AC 66 ms
70,732 KB
testcase_04 AC 63 ms
70,732 KB
testcase_05 AC 67 ms
70,428 KB
testcase_06 AC 75 ms
70,444 KB
testcase_07 AC 75 ms
70,344 KB
testcase_08 AC 83 ms
70,448 KB
testcase_09 AC 71 ms
70,432 KB
testcase_10 AC 778 ms
70,396 KB
testcase_11 AC 814 ms
70,556 KB
testcase_12 AC 854 ms
70,680 KB
testcase_13 AC 700 ms
70,460 KB
testcase_14 AC 760 ms
70,436 KB
testcase_15 AC 856 ms
70,552 KB
testcase_16 AC 771 ms
70,640 KB
testcase_17 AC 770 ms
70,388 KB
testcase_18 AC 919 ms
70,592 KB
testcase_19 AC 916 ms
70,588 KB
testcase_20 AC 52 ms
70,448 KB
testcase_21 AC 52 ms
70,580 KB
testcase_22 AC 918 ms
70,328 KB
testcase_23 AC 1,485 ms
70,680 KB
testcase_24 AC 1,314 ms
70,444 KB
testcase_25 AC 1,491 ms
70,508 KB
testcase_26 AC 51 ms
70,508 KB
testcase_27 AC 51 ms
70,456 KB
testcase_28 AC 1,307 ms
70,560 KB
testcase_29 AC 1,423 ms
70,380 KB
testcase_30 AC 1,306 ms
70,588 KB
testcase_31 AC 1,232 ms
70,380 KB
testcase_32 AC 1,351 ms
70,456 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]
            else : 
                j=n+1
    for i in range(1,n+1) :
        ans+=cnt[2*i*i]//2
    print(ans)
solve()
0