結果

問題 No.800 四平方定理
ユーザー sinsincoscossinsincoscos
提出日時 2019-03-17 22:10:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 62,044 KB
実行使用メモリ 130,516 KB
最終ジャッジ日時 2023-09-22 06:55:22
合計ジャッジ時間 4,106 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,000 KB
testcase_01 AC 4 ms
6,468 KB
testcase_02 AC 3 ms
6,132 KB
testcase_03 AC 3 ms
6,216 KB
testcase_04 AC 3 ms
6,156 KB
testcase_05 AC 4 ms
6,344 KB
testcase_06 AC 4 ms
8,892 KB
testcase_07 AC 3 ms
6,436 KB
testcase_08 AC 4 ms
9,032 KB
testcase_09 AC 4 ms
6,552 KB
testcase_10 AC 76 ms
68,768 KB
testcase_11 AC 83 ms
75,056 KB
testcase_12 AC 83 ms
75,004 KB
testcase_13 AC 76 ms
71,012 KB
testcase_14 AC 82 ms
74,924 KB
testcase_15 AC 83 ms
75,056 KB
testcase_16 AC 83 ms
76,968 KB
testcase_17 AC 83 ms
77,056 KB
testcase_18 AC 84 ms
77,156 KB
testcase_19 AC 81 ms
76,964 KB
testcase_20 AC 2 ms
5,336 KB
testcase_21 AC 2 ms
5,472 KB
testcase_22 AC 84 ms
77,272 KB
testcase_23 AC 154 ms
130,368 KB
testcase_24 AC 153 ms
130,208 KB
testcase_25 AC 154 ms
130,304 KB
testcase_26 AC 2 ms
5,580 KB
testcase_27 AC 3 ms
5,392 KB
testcase_28 AC 153 ms
130,516 KB
testcase_29 AC 155 ms
130,304 KB
testcase_30 AC 153 ms
130,260 KB
testcase_31 AC 142 ms
122,176 KB
testcase_32 AC 152 ms
130,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <unordered_map>
using namespace std;
typedef long long ll;
int N,D;
ll A[9000010] = {},B[9000010] = {};
int main(){
    cin >> N >> D;
//    unordered_map<int,ll> m2;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            A[i*i+j*j]++;
            B[i*i-j*j+N*N]++;
        }
    }
    ll ans = 0;
    for(int i=1;i<=2*N*N;i++){
        if(D-i+N*N>=0) ans += A[i]*B[D-i+N*N];
    }
    cout << ans << endl;
}
0