結果

問題 No.800 四平方定理
ユーザー sinsincoscossinsincoscos
提出日時 2019-03-17 22:10:05
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 350 ms
使用メモリ 127,048 KB
最終ジャッジ日時 2023-02-11 07:47:14
合計ジャッジ時間 4,766 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
5,152 KB
testcase_01 AC 3 ms
5,688 KB
testcase_02 AC 2 ms
5,152 KB
testcase_03 AC 2 ms
5,380 KB
testcase_04 AC 2 ms
5,084 KB
testcase_05 AC 2 ms
5,328 KB
testcase_06 AC 3 ms
6,276 KB
testcase_07 AC 3 ms
5,632 KB
testcase_08 AC 3 ms
6,264 KB
testcase_09 AC 3 ms
5,788 KB
testcase_10 AC 96 ms
64,624 KB
testcase_11 AC 109 ms
72,040 KB
testcase_12 AC 106 ms
70,912 KB
testcase_13 AC 100 ms
67,468 KB
testcase_14 AC 108 ms
72,156 KB
testcase_15 AC 108 ms
71,700 KB
testcase_16 AC 110 ms
72,772 KB
testcase_17 AC 111 ms
72,904 KB
testcase_18 AC 110 ms
72,680 KB
testcase_19 AC 113 ms
72,652 KB
testcase_20 AC 2 ms
4,908 KB
testcase_21 AC 2 ms
5,152 KB
testcase_22 AC 111 ms
72,772 KB
testcase_23 AC 210 ms
127,048 KB
testcase_24 AC 210 ms
127,040 KB
testcase_25 AC 205 ms
126,656 KB
testcase_26 AC 2 ms
5,152 KB
testcase_27 AC 1 ms
5,156 KB
testcase_28 AC 206 ms
126,412 KB
testcase_29 AC 208 ms
126,752 KB
testcase_30 AC 207 ms
126,544 KB
testcase_31 AC 193 ms
117,936 KB
testcase_32 AC 217 ms
127,040 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