結果

問題 No.800 四平方定理
ユーザー le_panda_noirle_panda_noir
提出日時 2020-06-13 19:37:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 521 bytes
コンパイル時間 981 ms
コンパイル使用メモリ 85,200 KB
実行使用メモリ 120,004 KB
最終ジャッジ日時 2023-09-08 02:13:15
合計ジャッジ時間 5,813 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
10,332 KB
testcase_01 AC 42 ms
8,212 KB
testcase_02 AC 28 ms
6,708 KB
testcase_03 AC 33 ms
7,284 KB
testcase_04 AC 27 ms
6,600 KB
testcase_05 AC 32 ms
7,092 KB
testcase_06 AC 54 ms
9,180 KB
testcase_07 AC 36 ms
7,772 KB
testcase_08 AC 52 ms
9,384 KB
testcase_09 AC 44 ms
8,340 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>

using namespace std;
using ll = long long;

void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int N, D;
  ins(N, D);

  map<int, int> m, m2;
  rep(i, N) rep(j, N) {
    ++m[(i+1)*(i+1)+(j+1)*(j+1)];
    ++m2[(i+1)*(i+1)-(j+1)*(j+1)];
  }
  ll ans = 0;
  for (const auto& [wz, count]:m2) {
    ans += m[wz+D] * count;
  }
  cout << ans << endl;

  return 0;
}
0