結果

問題 No.800 四平方定理
ユーザー taki_gtaki_g
提出日時 2019-03-18 15:25:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,050 bytes
コンパイル時間 1,419 ms
コンパイル使用メモリ 165,820 KB
実行使用メモリ 159,556 KB
最終ジャッジ日時 2023-09-25 12:36:13
合計ジャッジ時間 5,989 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
159,264 KB
testcase_01 AC 59 ms
159,416 KB
testcase_02 AC 57 ms
159,308 KB
testcase_03 AC 57 ms
159,300 KB
testcase_04 AC 57 ms
159,256 KB
testcase_05 AC 58 ms
159,256 KB
testcase_06 AC 58 ms
159,308 KB
testcase_07 AC 56 ms
159,556 KB
testcase_08 AC 56 ms
159,188 KB
testcase_09 AC 58 ms
159,304 KB
testcase_10 AC 96 ms
159,252 KB
testcase_11 AC 98 ms
159,336 KB
testcase_12 AC 111 ms
159,320 KB
testcase_13 AC 90 ms
159,316 KB
testcase_14 AC 94 ms
159,372 KB
testcase_15 AC 102 ms
159,264 KB
testcase_16 AC 95 ms
159,212 KB
testcase_17 AC 95 ms
159,440 KB
testcase_18 AC 107 ms
159,288 KB
testcase_19 AC 109 ms
159,436 KB
testcase_20 AC 58 ms
159,412 KB
testcase_21 AC 57 ms
159,340 KB
testcase_22 AC 109 ms
159,308 KB
testcase_23 AC 148 ms
159,292 KB
testcase_24 AC 135 ms
159,376 KB
testcase_25 AC 149 ms
159,388 KB
testcase_26 AC 58 ms
159,216 KB
testcase_27 AC 58 ms
159,184 KB
testcase_28 AC 139 ms
159,260 KB
testcase_29 AC 144 ms
159,288 KB
testcase_30 AC 134 ms
159,356 KB
testcase_31 AC 128 ms
159,244 KB
testcase_32 AC 138 ms
159,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((ll)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

int main(){
  ll N,D;
  cin >> N >> D;
  ll MAX = 1e7;
  ll ans = 0;
  vector<ll> count1(MAX);
  vector<ll> count2(MAX);
  REP(i,1,N+1)REP(j,1,N+1){
    ll temp1 = i*i+j*j;
    ll temp2 = i*i-j*j+D;
    count1[temp1]++;
    if(temp2<=0)continue;
    count2[temp2]++;
  }
  
  rep(i,MAX){
    ans += count1[i]*count2[i];
  }
  
  cout << ans << endl;



  return 0;
}
0