結果

問題 No.800 四平方定理
ユーザー sinsincoscossinsincoscos
提出日時 2019-03-17 22:07:53
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 452 bytes
コンパイル時間 825 ms
コンパイル使用メモリ 61,544 KB
実行使用メモリ 81,352 KB
最終ジャッジ日時 2023-09-22 06:45:28
合計ジャッジ時間 6,574 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,088 KB
testcase_01 AC 3 ms
6,704 KB
testcase_02 AC 3 ms
6,168 KB
testcase_03 AC 3 ms
6,260 KB
testcase_04 AC 3 ms
6,112 KB
testcase_05 AC 2 ms
6,276 KB
testcase_06 AC 4 ms
6,972 KB
testcase_07 AC 3 ms
6,496 KB
testcase_08 AC 4 ms
6,736 KB
testcase_09 AC 3 ms
6,560 KB
testcase_10 AC 69 ms
68,968 KB
testcase_11 AC 72 ms
75,060 KB
testcase_12 AC 72 ms
73,120 KB
testcase_13 AC 65 ms
68,868 KB
testcase_14 AC 73 ms
74,968 KB
testcase_15 AC 73 ms
72,916 KB
testcase_16 AC 75 ms
77,016 KB
testcase_17 AC 72 ms
77,044 KB
testcase_18 AC 75 ms
77,060 KB
testcase_19 AC 72 ms
77,180 KB
testcase_20 AC 2 ms
5,388 KB
testcase_21 AC 2 ms
5,492 KB
testcase_22 AC 74 ms
77,060 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 2 ms
5,344 KB
testcase_27 AC 2 ms
5,388 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <unordered_map>
using namespace std;
typedef long long ll;
int N,D;
ll A[5000010] = {},B[5000010] = {};
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