結果

問題 No.800 四平方定理
ユーザー beetbeet
提出日時 2019-03-18 11:35:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,326 ms / 2,000 ms
コード長 574 bytes
コンパイル時間 2,077 ms
コンパイル使用メモリ 206,260 KB
実行使用メモリ 135,832 KB
最終ジャッジ日時 2023-09-25 04:03:14
合計ジャッジ時間 20,771 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,380 KB
testcase_01 AC 9 ms
5,788 KB
testcase_02 AC 6 ms
4,568 KB
testcase_03 AC 8 ms
5,140 KB
testcase_04 AC 7 ms
4,892 KB
testcase_05 AC 7 ms
5,408 KB
testcase_06 AC 10 ms
5,884 KB
testcase_07 AC 10 ms
6,048 KB
testcase_08 AC 14 ms
7,128 KB
testcase_09 AC 9 ms
5,776 KB
testcase_10 AC 606 ms
68,984 KB
testcase_11 AC 643 ms
77,948 KB
testcase_12 AC 671 ms
79,628 KB
testcase_13 AC 563 ms
67,276 KB
testcase_14 AC 623 ms
75,316 KB
testcase_15 AC 680 ms
78,772 KB
testcase_16 AC 635 ms
75,744 KB
testcase_17 AC 629 ms
73,948 KB
testcase_18 AC 729 ms
84,508 KB
testcase_19 AC 738 ms
85,408 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 739 ms
82,392 KB
testcase_23 AC 1,326 ms
135,832 KB
testcase_24 AC 1,206 ms
129,856 KB
testcase_25 AC 1,309 ms
134,044 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1,211 ms
129,676 KB
testcase_29 AC 1,281 ms
135,212 KB
testcase_30 AC 1,197 ms
126,864 KB
testcase_31 AC 1,121 ms
120,200 KB
testcase_32 AC 1,216 ms
128,088 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) ans+=cnt[v];
    }
  }
  cout<<ans<<endl;
  return 0;
}
0