結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,408 KB
testcase_01 AC 4 ms
7,480 KB
testcase_02 AC 3 ms
5,388 KB
testcase_03 AC 2 ms
5,476 KB
testcase_04 AC 3 ms
5,424 KB
testcase_05 AC 3 ms
5,368 KB
testcase_06 AC 4 ms
7,576 KB
testcase_07 AC 3 ms
5,424 KB
testcase_08 AC 4 ms
7,416 KB
testcase_09 AC 4 ms
7,644 KB
testcase_10 AC 58 ms
36,084 KB
testcase_11 AC 67 ms
40,184 KB
testcase_12 AC 68 ms
40,184 KB
testcase_13 AC 62 ms
38,132 KB
testcase_14 AC 69 ms
40,252 KB
testcase_15 AC 72 ms
40,300 KB
testcase_16 AC 67 ms
40,244 KB
testcase_17 AC 71 ms
40,440 KB
testcase_18 AC 69 ms
40,212 KB
testcase_19 AC 68 ms
40,240 KB
testcase_20 AC 2 ms
5,340 KB
testcase_21 AC 2 ms
5,364 KB
testcase_22 AC 67 ms
40,296 KB
testcase_23 AC 132 ms
65,812 KB
testcase_24 AC 128 ms
65,872 KB
testcase_25 AC 136 ms
65,740 KB
testcase_26 AC 2 ms
5,484 KB
testcase_27 AC 2 ms
5,428 KB
testcase_28 AC 129 ms
65,524 KB
testcase_29 AC 136 ms
65,724 KB
testcase_30 AC 126 ms
65,568 KB
testcase_31 AC 121 ms
62,680 KB
testcase_32 AC 131 ms
65,928 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