結果

問題 No.800 四平方定理
ユーザー shop_oneshop_one
提出日時 2020-04-15 15:50:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 716 bytes
コンパイル時間 870 ms
コンパイル使用メモリ 93,908 KB
実行使用メモリ 72,148 KB
最終ジャッジ日時 2023-07-24 23:24:52
合計ジャッジ時間 4,396 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
71,700 KB
testcase_01 AC 18 ms
72,148 KB
testcase_02 AC 18 ms
71,588 KB
testcase_03 AC 19 ms
71,596 KB
testcase_04 AC 18 ms
72,144 KB
testcase_05 AC 20 ms
71,592 KB
testcase_06 AC 18 ms
71,704 KB
testcase_07 AC 18 ms
72,144 KB
testcase_08 AC 19 ms
71,644 KB
testcase_09 AC 18 ms
71,644 KB
testcase_10 AC 39 ms
72,088 KB
testcase_11 AC 41 ms
71,592 KB
testcase_12 AC 41 ms
71,712 KB
testcase_13 AC 39 ms
71,904 KB
testcase_14 AC 43 ms
72,004 KB
testcase_15 AC 43 ms
71,764 KB
testcase_16 AC 40 ms
72,084 KB
testcase_17 AC 41 ms
71,652 KB
testcase_18 AC 43 ms
71,888 KB
testcase_19 AC 44 ms
72,084 KB
testcase_20 AC 18 ms
72,084 KB
testcase_21 AC 18 ms
72,136 KB
testcase_22 AC 45 ms
71,652 KB
testcase_23 AC 74 ms
71,764 KB
testcase_24 AC 69 ms
71,828 KB
testcase_25 AC 73 ms
71,884 KB
testcase_26 AC 17 ms
72,088 KB
testcase_27 AC 18 ms
71,656 KB
testcase_28 AC 67 ms
71,748 KB
testcase_29 AC 70 ms
71,948 KB
testcase_30 AC 65 ms
71,824 KB
testcase_31 AC 62 ms
72,012 KB
testcase_32 AC 64 ms
72,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
#define MAX 2*(2100*2100)
vector<ll> mv(MAX,0);
signed main(){
  init_io();
  ll n,d,ans=0;
  cin >> n >> d;
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=n;j++){
      mv[i*i+j*j]++;
    }
  }
  for(ll w=1;w<=n;w++){
    for(ll z=1;z<=n;z++){
      ll x = d + w*w - z*z;
      if(x>=0&&x<MAX){
        ans += mv[x];
      }
    }
  }
  cout << ans << endl;
}
0