結果

問題 No.800 四平方定理
ユーザー Kutimoti_TKutimoti_T
提出日時 2019-03-17 21:32:10
言語 C++11
(gcc 8.5.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 489 bytes
コンパイル時間 990 ms
使用メモリ 65,968 KB
最終ジャッジ日時 2023-02-11 04:32:23
合計ジャッジ時間 3,567 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,900 KB
testcase_01 AC 2 ms
5,152 KB
testcase_02 AC 2 ms
5,156 KB
testcase_03 AC 2 ms
4,904 KB
testcase_04 AC 2 ms
4,904 KB
testcase_05 AC 2 ms
4,904 KB
testcase_06 AC 2 ms
4,920 KB
testcase_07 AC 2 ms
5,156 KB
testcase_08 AC 2 ms
4,936 KB
testcase_09 AC 2 ms
5,152 KB
testcase_10 AC 31 ms
34,384 KB
testcase_11 AC 37 ms
38,228 KB
testcase_12 AC 38 ms
37,620 KB
testcase_13 AC 38 ms
35,932 KB
testcase_14 AC 36 ms
38,288 KB
testcase_15 AC 35 ms
38,056 KB
testcase_16 AC 37 ms
38,660 KB
testcase_17 AC 36 ms
38,596 KB
testcase_18 AC 36 ms
38,496 KB
testcase_19 AC 34 ms
38,440 KB
testcase_20 AC 2 ms
5,152 KB
testcase_21 AC 2 ms
5,152 KB
testcase_22 AC 44 ms
38,640 KB
testcase_23 AC 98 ms
65,968 KB
testcase_24 AC 93 ms
65,860 KB
testcase_25 AC 93 ms
65,796 KB
testcase_26 AC 2 ms
5,152 KB
testcase_27 AC 1 ms
5,156 KB
testcase_28 AC 97 ms
65,692 KB
testcase_29 AC 96 ms
65,820 KB
testcase_30 AC 89 ms
65,684 KB
testcase_31 AC 81 ms
61,440 KB
testcase_32 AC 95 ms
65,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 mp[2000 * 2000 * 2 + 10];

int main() {
  i64 N,D;
  cin >> N >> D;
  rep(i,1,N) rep(j,1,N) {
    mp[j * j - i * i + 2000 * 2000]++;
  }
  i64 ans = 0;
  rep(i,1,N) rep(j,1,N) {
    i64 XX = i * i + j * j - D + 2000 * 2000;
    if(XX < 0 || XX >= 2000 * 2000 * 2 + 10) continue;
    ans += mp[XX];
  }
  cout << ans << endl;
}
0