結果

問題 No.800 四平方定理
ユーザー shop_oneshop_one
提出日時 2020-04-15 15:50:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 716 bytes
コンパイル時間 942 ms
コンパイル使用メモリ 95,184 KB
実行使用メモリ 72,324 KB
最終ジャッジ日時 2024-04-09 18:43:17
合計ジャッジ時間 3,790 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
72,040 KB
testcase_01 AC 20 ms
72,224 KB
testcase_02 AC 20 ms
72,280 KB
testcase_03 AC 20 ms
72,104 KB
testcase_04 AC 20 ms
72,144 KB
testcase_05 AC 20 ms
72,040 KB
testcase_06 AC 20 ms
72,108 KB
testcase_07 AC 20 ms
72,316 KB
testcase_08 AC 20 ms
72,108 KB
testcase_09 AC 21 ms
71,972 KB
testcase_10 AC 45 ms
72,084 KB
testcase_11 AC 47 ms
71,968 KB
testcase_12 AC 47 ms
72,212 KB
testcase_13 AC 44 ms
72,176 KB
testcase_14 AC 46 ms
72,080 KB
testcase_15 AC 49 ms
72,248 KB
testcase_16 AC 47 ms
72,100 KB
testcase_17 AC 47 ms
71,972 KB
testcase_18 AC 51 ms
72,144 KB
testcase_19 AC 52 ms
72,324 KB
testcase_20 AC 19 ms
71,976 KB
testcase_21 AC 19 ms
72,032 KB
testcase_22 AC 50 ms
71,972 KB
testcase_23 AC 94 ms
71,964 KB
testcase_24 AC 82 ms
72,144 KB
testcase_25 AC 93 ms
72,036 KB
testcase_26 AC 19 ms
72,256 KB
testcase_27 AC 20 ms
72,108 KB
testcase_28 AC 84 ms
72,108 KB
testcase_29 AC 89 ms
72,180 KB
testcase_30 AC 85 ms
72,124 KB
testcase_31 AC 81 ms
72,112 KB
testcase_32 AC 87 ms
72,168 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