結果

問題 No.800 四平方定理
ユーザー beetbeet
提出日時 2019-03-18 11:34:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,617 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 207,452 KB
実行使用メモリ 160,732 KB
最終ジャッジ日時 2023-09-25 04:01:31
合計ジャッジ時間 26,139 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,748 KB
testcase_01 AC 12 ms
6,272 KB
testcase_02 AC 9 ms
5,160 KB
testcase_03 AC 10 ms
5,696 KB
testcase_04 AC 8 ms
5,156 KB
testcase_05 AC 9 ms
5,700 KB
testcase_06 AC 15 ms
6,672 KB
testcase_07 AC 11 ms
6,008 KB
testcase_08 AC 15 ms
7,008 KB
testcase_09 AC 13 ms
6,252 KB
testcase_10 AC 713 ms
78,896 KB
testcase_11 AC 888 ms
92,188 KB
testcase_12 AC 848 ms
90,332 KB
testcase_13 AC 806 ms
83,836 KB
testcase_14 AC 898 ms
92,748 KB
testcase_15 AC 871 ms
90,060 KB
testcase_16 AC 916 ms
93,176 KB
testcase_17 AC 917 ms
91,364 KB
testcase_18 AC 853 ms
91,708 KB
testcase_19 AC 848 ms
92,704 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 862 ms
89,744 KB
testcase_23 AC 1,606 ms
155,436 KB
testcase_24 AC 1,613 ms
160,732 KB
testcase_25 AC 1,573 ms
153,328 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1,609 ms
160,520 KB
testcase_29 AC 1,617 ms
159,600 KB
testcase_30 AC 1,598 ms
157,696 KB
testcase_31 AC 1,525 ms
148,992 KB
testcase_32 AC 1,603 ms
157,572 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;
      ans+=cnt[v];
    }
  }
  cout<<ans<<endl;
  return 0;
}
0