結果

問題 No.800 四平方定理
ユーザー oxyshoweroxyshower
提出日時 2019-04-06 17:41:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,525 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 1,220 ms
コンパイル使用メモリ 150,416 KB
実行使用メモリ 67,268 KB
最終ジャッジ日時 2023-09-06 15:06:58
合計ジャッジ時間 22,127 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,376 KB
testcase_01 AC 20 ms
4,616 KB
testcase_02 AC 14 ms
4,416 KB
testcase_03 AC 16 ms
4,376 KB
testcase_04 AC 14 ms
4,380 KB
testcase_05 AC 16 ms
4,380 KB
testcase_06 AC 23 ms
4,708 KB
testcase_07 AC 17 ms
4,784 KB
testcase_08 AC 13 ms
4,860 KB
testcase_09 AC 20 ms
4,804 KB
testcase_10 AC 705 ms
34,092 KB
testcase_11 AC 759 ms
53,868 KB
testcase_12 AC 797 ms
53,848 KB
testcase_13 AC 643 ms
35,680 KB
testcase_14 AC 700 ms
53,644 KB
testcase_15 AC 796 ms
54,360 KB
testcase_16 AC 706 ms
53,916 KB
testcase_17 AC 709 ms
54,684 KB
testcase_18 AC 856 ms
53,996 KB
testcase_19 AC 861 ms
53,852 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 878 ms
53,840 KB
testcase_23 AC 1,500 ms
66,376 KB
testcase_24 AC 1,315 ms
67,212 KB
testcase_25 AC 1,525 ms
67,268 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1,296 ms
66,432 KB
testcase_29 AC 1,429 ms
66,472 KB
testcase_30 AC 1,307 ms
66,192 KB
testcase_31 AC 1,212 ms
62,696 KB
testcase_32 AC 1,346 ms
66,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N,D; cin >> N >> D;
  vector<int> xy,zw;
  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= N; j++){
      xy.push_back(i*i + j*j);
      zw.push_back(i*i - j*j);
    }
  }
  sort(zw.begin(),zw.end());

  int ans = 0;
  for(auto p : xy){
    auto r = upper_bound(zw.begin(),zw.end(),D - p);
    auto l = lower_bound(zw.begin(),zw.end(),D - p);
    ans += r - l;
  }
  cout << ans << endl;

  return 0;
}
0