結果

問題 No.800 四平方定理
ユーザー beetbeet
提出日時 2019-03-18 11:29:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,589 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 2,027 ms
コンパイル使用メモリ 207,820 KB
実行使用メモリ 50,036 KB
最終ジャッジ日時 2023-09-25 03:46:59
合計ジャッジ時間 22,800 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 8 ms
4,380 KB
testcase_02 AC 6 ms
4,376 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 6 ms
4,384 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 9 ms
4,444 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 10 ms
4,444 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 539 ms
26,492 KB
testcase_11 AC 702 ms
29,040 KB
testcase_12 AC 736 ms
28,396 KB
testcase_13 AC 617 ms
27,672 KB
testcase_14 AC 695 ms
28,912 KB
testcase_15 AC 749 ms
28,616 KB
testcase_16 AC 720 ms
29,320 KB
testcase_17 AC 651 ms
29,300 KB
testcase_18 AC 690 ms
28,848 KB
testcase_19 AC 756 ms
29,040 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 758 ms
29,180 KB
testcase_23 AC 1,589 ms
49,848 KB
testcase_24 AC 1,379 ms
49,900 KB
testcase_25 AC 1,538 ms
49,976 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1,463 ms
49,880 KB
testcase_29 AC 1,448 ms
50,036 KB
testcase_30 AC 1,499 ms
49,848 KB
testcase_31 AC 1,401 ms
47,660 KB
testcase_32 AC 1,444 ms
50,032 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&&cnt.count(v)) ans+=cnt[v];
    }
  }
  cout<<ans<<endl;
  return 0;
}
0