結果

問題 No.800 四平方定理
ユーザー beetbeet
提出日時 2019-03-18 11:27:56
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 549 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 206,560 KB
実行使用メモリ 94,960 KB
最終ジャッジ日時 2023-09-25 03:44:02
合計ジャッジ時間 29,985 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 AC 11 ms
5,448 KB
testcase_02 AC 7 ms
4,376 KB
testcase_03 AC 8 ms
4,440 KB
testcase_04 AC 8 ms
4,528 KB
testcase_05 AC 8 ms
4,492 KB
testcase_06 AC 12 ms
5,448 KB
testcase_07 AC 13 ms
5,464 KB
testcase_08 AC 18 ms
6,328 KB
testcase_09 AC 10 ms
4,672 KB
testcase_10 AC 872 ms
48,892 KB
testcase_11 AC 980 ms
52,300 KB
testcase_12 AC 972 ms
54,160 KB
testcase_13 AC 797 ms
44,708 KB
testcase_14 AC 950 ms
50,064 KB
testcase_15 AC 981 ms
53,356 KB
testcase_16 AC 916 ms
50,188 KB
testcase_17 AC 937 ms
48,476 KB
testcase_18 AC 1,100 ms
59,184 KB
testcase_19 AC 1,208 ms
82,508 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1,111 ms
56,944 KB
testcase_23 TLE -
testcase_24 AC 1,899 ms
88,696 KB
testcase_25 TLE -
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1,859 ms
88,904 KB
testcase_29 AC 1,950 ms
94,320 KB
testcase_30 AC 1,843 ms
86,064 KB
testcase_31 AC 1,711 ms
84,076 KB
testcase_32 AC 1,859 ms
87,124 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;
  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