結果

問題 No.800 四平方定理
ユーザー lumeffluxlumefflux
提出日時 2019-03-18 02:34:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 520 bytes
コンパイル時間 1,553 ms
コンパイル使用メモリ 165,948 KB
実行使用メモリ 128,364 KB
最終ジャッジ日時 2023-09-22 16:31:05
合計ジャッジ時間 5,487 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
128,128 KB
testcase_01 AC 64 ms
127,980 KB
testcase_02 AC 48 ms
128,228 KB
testcase_03 AC 47 ms
128,144 KB
testcase_04 AC 47 ms
128,032 KB
testcase_05 AC 47 ms
128,356 KB
testcase_06 AC 47 ms
128,360 KB
testcase_07 AC 47 ms
128,076 KB
testcase_08 AC 47 ms
128,176 KB
testcase_09 AC 47 ms
128,180 KB
testcase_10 AC 81 ms
128,080 KB
testcase_11 AC 84 ms
128,076 KB
testcase_12 AC 88 ms
128,360 KB
testcase_13 AC 80 ms
128,284 KB
testcase_14 AC 83 ms
128,032 KB
testcase_15 AC 89 ms
128,148 KB
testcase_16 AC 82 ms
128,236 KB
testcase_17 AC 84 ms
128,364 KB
testcase_18 AC 91 ms
128,080 KB
testcase_19 AC 92 ms
128,168 KB
testcase_20 AC 46 ms
128,116 KB
testcase_21 AC 48 ms
128,224 KB
testcase_22 AC 96 ms
128,232 KB
testcase_23 AC 135 ms
128,128 KB
testcase_24 AC 122 ms
128,072 KB
testcase_25 AC 131 ms
128,032 KB
testcase_26 AC 46 ms
128,224 KB
testcase_27 AC 46 ms
128,172 KB
testcase_28 AC 118 ms
128,360 KB
testcase_29 AC 126 ms
128,284 KB
testcase_30 AC 120 ms
128,124 KB
testcase_31 AC 112 ms
128,140 KB
testcase_32 AC 121 ms
128,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include <vector>
using namespace std;

#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
int main(){
    long long N, D;
    cin >> N >> D;
    vector<long long> c1(8000001), c2(8000001) ;
    REP(i, 1, N + 1)REP(j, 1, N + 1){
      	c2[i*i + j*j]++;
        int s = i*i - j*j + D;
        if (s >= 1) {
            c1[s]++;
        }
    }
    long long ans = 0;
    rep(i, 8000001){
        ans += c1[i]*c2[i];
    }
    cout << ans << endl;
    return 0;
}
0