結果

問題 No.800 四平方定理
ユーザー satou_a_mansatou_a_man
提出日時 2019-03-17 21:58:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 668 bytes
コンパイル時間 1,244 ms
コンパイル使用メモリ 145,172 KB
実行使用メモリ 34,500 KB
最終ジャッジ日時 2023-09-22 05:54:40
合計ジャッジ時間 3,239 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
34,284 KB
testcase_01 AC 12 ms
34,240 KB
testcase_02 AC 12 ms
34,236 KB
testcase_03 AC 12 ms
34,248 KB
testcase_04 AC 13 ms
34,248 KB
testcase_05 AC 11 ms
34,208 KB
testcase_06 AC 12 ms
34,236 KB
testcase_07 AC 12 ms
34,340 KB
testcase_08 AC 13 ms
34,244 KB
testcase_09 AC 12 ms
34,232 KB
testcase_10 AC 27 ms
34,264 KB
testcase_11 AC 28 ms
34,304 KB
testcase_12 AC 29 ms
34,496 KB
testcase_13 AC 27 ms
34,312 KB
testcase_14 AC 30 ms
34,240 KB
testcase_15 AC 29 ms
34,288 KB
testcase_16 AC 29 ms
34,296 KB
testcase_17 AC 27 ms
34,244 KB
testcase_18 AC 30 ms
34,460 KB
testcase_19 AC 30 ms
34,176 KB
testcase_20 AC 11 ms
34,280 KB
testcase_21 AC 11 ms
34,300 KB
testcase_22 AC 30 ms
34,244 KB
testcase_23 AC 65 ms
34,240 KB
testcase_24 AC 59 ms
34,304 KB
testcase_25 AC 62 ms
34,232 KB
testcase_26 AC 12 ms
34,304 KB
testcase_27 AC 13 ms
34,308 KB
testcase_28 AC 60 ms
34,256 KB
testcase_29 AC 62 ms
34,228 KB
testcase_30 AC 63 ms
34,288 KB
testcase_31 AC 54 ms
34,332 KB
testcase_32 AC 61 ms
34,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll N,D;
  cin>>N>>D;
  vector<int> xy_ans(8000000+1);
  repeat(x,1,N+1) {
    repeat(y,1,N+1) {
      xy_ans[x*x+y*y]++;
    }
  }
  ll ans=0;
  repeat(z,1,N+1) {
    repeat(w,1,N+1) {
      ll c=D+w*w-z*z;
      if(c>=0) {
        ans+=xy_ans[c];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
0