結果

問題 No.800 四平方定理
ユーザー Fu_LFu_L
提出日時 2020-12-21 23:43:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 1,531 ms
コンパイル使用メモリ 166,588 KB
実行使用メモリ 104,720 KB
最終ジャッジ日時 2023-10-21 12:05:55
合計ジャッジ時間 5,184 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
8,032 KB
testcase_01 AC 7 ms
8,328 KB
testcase_02 AC 7 ms
8,140 KB
testcase_03 AC 7 ms
8,192 KB
testcase_04 AC 7 ms
8,168 KB
testcase_05 AC 7 ms
8,232 KB
testcase_06 AC 8 ms
10,436 KB
testcase_07 AC 8 ms
10,188 KB
testcase_08 AC 8 ms
11,760 KB
testcase_09 AC 8 ms
8,328 KB
testcase_10 AC 60 ms
57,540 KB
testcase_11 AC 65 ms
61,636 KB
testcase_12 AC 66 ms
63,684 KB
testcase_13 AC 55 ms
55,492 KB
testcase_14 AC 61 ms
59,588 KB
testcase_15 AC 67 ms
63,684 KB
testcase_16 AC 62 ms
59,588 KB
testcase_17 AC 61 ms
59,588 KB
testcase_18 AC 75 ms
67,780 KB
testcase_19 AC 73 ms
67,780 KB
testcase_20 AC 6 ms
5,616 KB
testcase_21 AC 6 ms
5,616 KB
testcase_22 AC 74 ms
67,780 KB
testcase_23 AC 128 ms
104,720 KB
testcase_24 AC 113 ms
98,576 KB
testcase_25 AC 127 ms
104,692 KB
testcase_26 AC 6 ms
5,616 KB
testcase_27 AC 6 ms
7,664 KB
testcase_28 AC 114 ms
98,532 KB
testcase_29 AC 122 ms
102,652 KB
testcase_30 AC 112 ms
98,540 KB
testcase_31 AC 103 ms
94,404 KB
testcase_32 AC 116 ms
100,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,d;
ll c1[8000005],c2[5000005];
ll ans;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n>>d;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            c1[i*i+j*j]++;
            if(i*i-j*j+d>=0){
                c2[i*i-j*j+d]++;
            }
        }
    }
    for(ll i=2;i<=5000000;i++){
        ans+=c1[i]*c2[i];
    }
    cout<<ans<<endl;

}
0