結果

問題 No.800 四平方定理
ユーザー beetbeet
提出日時 2019-03-18 11:33:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,115 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 2,094 ms
コンパイル使用メモリ 206,856 KB
実行使用メモリ 102,896 KB
最終ジャッジ日時 2023-09-25 03:58:54
合計ジャッジ時間 18,303 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,380 KB
testcase_01 AC 7 ms
5,172 KB
testcase_02 AC 5 ms
4,376 KB
testcase_03 AC 5 ms
4,732 KB
testcase_04 AC 5 ms
4,384 KB
testcase_05 AC 5 ms
4,736 KB
testcase_06 AC 8 ms
5,360 KB
testcase_07 AC 7 ms
4,892 KB
testcase_08 AC 9 ms
5,408 KB
testcase_09 AC 7 ms
5,172 KB
testcase_10 AC 487 ms
52,512 KB
testcase_11 AC 528 ms
60,272 KB
testcase_12 AC 543 ms
59,696 KB
testcase_13 AC 509 ms
55,904 KB
testcase_14 AC 543 ms
60,216 KB
testcase_15 AC 561 ms
59,908 KB
testcase_16 AC 538 ms
60,228 KB
testcase_17 AC 560 ms
60,240 KB
testcase_18 AC 578 ms
60,300 KB
testcase_19 AC 561 ms
60,324 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 589 ms
60,212 KB
testcase_23 AC 1,110 ms
102,600 KB
testcase_24 AC 1,038 ms
102,572 KB
testcase_25 AC 1,115 ms
102,656 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1,029 ms
102,396 KB
testcase_29 AC 1,061 ms
102,632 KB
testcase_30 AC 1,059 ms
102,612 KB
testcase_31 AC 954 ms
95,116 KB
testcase_32 AC 1,069 ms
102,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


//INSERT ABOVE HERE
signed main(){
  Int n,d;
  cin>>n>>d;
  unordered_map<Int, Int> cnt;
  cnt.reserve(2*n*n);
  
  for(Int i=1;i<=n;i++)
    for(Int j=1;j<=n;j++)
      cnt[i*i+j*j]++;
  
  Int ans=0;
  for(Int i=1;i<=n;i++){
    for(Int j=1;j<=n;j++){
      Int v=i*i-j*j+d;
      if(v>0&&cnt.count(v)) ans+=cnt[v];
    }
  }
  cout<<ans<<endl;
  return 0;
}
0