結果

問題 No.800 四平方定理
ユーザー beetbeet
提出日時 2019-03-17 21:25:30
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 1,346 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 3,091 ms
使用メモリ 167,008 KB
最終ジャッジ日時 2023-02-11 03:47:21
合計ジャッジ時間 22,264 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 8 ms
5,496 KB
testcase_01 AC 12 ms
6,004 KB
testcase_02 AC 9 ms
6,144 KB
testcase_03 AC 11 ms
6,360 KB
testcase_04 AC 10 ms
5,552 KB
testcase_05 AC 10 ms
5,600 KB
testcase_06 AC 16 ms
8,172 KB
testcase_07 AC 11 ms
5,728 KB
testcase_08 AC 17 ms
8,160 KB
testcase_09 AC 12 ms
6,048 KB
testcase_10 AC 507 ms
85,092 KB
testcase_11 AC 612 ms
88,036 KB
testcase_12 AC 572 ms
86,196 KB
testcase_13 AC 545 ms
85,028 KB
testcase_14 AC 591 ms
88,756 KB
testcase_15 AC 566 ms
85,920 KB
testcase_16 AC 608 ms
89,292 KB
testcase_17 AC 586 ms
87,508 KB
testcase_18 AC 610 ms
87,828 KB
testcase_19 AC 623 ms
88,492 KB
testcase_20 AC 2 ms
4,904 KB
testcase_21 AC 2 ms
4,900 KB
testcase_22 AC 616 ms
85,664 KB
testcase_23 AC 1,272 ms
166,900 KB
testcase_24 AC 1,319 ms
166,956 KB
testcase_25 AC 1,291 ms
167,008 KB
testcase_26 AC 1 ms
5,156 KB
testcase_27 AC 2 ms
4,900 KB
testcase_28 AC 1,346 ms
166,904 KB
testcase_29 AC 1,325 ms
166,972 KB
testcase_30 AC 1,300 ms
166,900 KB
testcase_31 AC 1,187 ms
166,912 KB
testcase_32 AC 1,276 ms
166,976 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;}


#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T,typename U> 
using gmap = cc_hash_table<T, U, hash<T> >;

//INSERT ABOVE HERE
signed main(){
  Int n,d;
  cin>>n>>d;
  gmap<Int, Int> cnt;
  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;
      ans+=cnt[v];
    }
  }
  cout<<ans<<endl;
  return 0;
}
0