結果

問題 No.800 四平方定理
ユーザー monnumonnu
提出日時 2020-09-29 22:19:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 435 bytes
コンパイル時間 2,340 ms
コンパイル使用メモリ 170,996 KB
実行使用メモリ 87,076 KB
最終ジャッジ日時 2023-09-17 20:18:43
合計ジャッジ時間 31,356 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
5,016 KB
testcase_01 AC 26 ms
6,348 KB
testcase_02 AC 17 ms
5,324 KB
testcase_03 AC 20 ms
5,744 KB
testcase_04 AC 17 ms
5,224 KB
testcase_05 AC 19 ms
5,544 KB
testcase_06 AC 31 ms
7,012 KB
testcase_07 AC 23 ms
5,928 KB
testcase_08 AC 29 ms
7,080 KB
testcase_09 AC 27 ms
6,332 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000000000000
#define MOD 1000000007
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int N,D;
  cin>>N>>D;

  map<int,int> m;
  for(int i=1;i<=N;i++){
    m[i*i*2]++;
    for(int j=i+1;j<=N;j++){
      m[i*i+j*j]+=2;
    }
  }

  int ans=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      ans+=m[i*i-j*j+D];
    }
  }

  cout<<ans<<endl;

}
0