結果

問題 No.800 四平方定理
ユーザー ankiganbaroankiganbaro
提出日時 2019-03-17 22:58:41
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 726 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 73,288 KB
実行使用メモリ 7,672 KB
最終ジャッジ日時 2023-09-22 09:24:40
合計ジャッジ時間 4,918 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
7,476 KB
testcase_01 AC 25 ms
4,376 KB
testcase_02 AC 17 ms
4,380 KB
testcase_03 AC 19 ms
4,380 KB
testcase_04 AC 14 ms
4,376 KB
testcase_05 AC 18 ms
4,376 KB
testcase_06 AC 33 ms
4,376 KB
testcase_07 AC 10 ms
4,380 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 27 ms
4,380 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000
#define ll long long int
using namespace std;




int main(){
  ll ans = 0;

ll N,D; cin>>N>>D;

for(int x=1;x<=N;x++){
  for(int y=1;y<=x;y++){
    for(int z=1;z<=y;z++){
      ll  test = x*x + y*y + z*z - D;
      if(test<=0) continue;
      double root = sqrt(test);
      if(root != int(root)) continue;
      if(root > N) continue;
      int cnt = 1;
      if(x==y) cnt++;
      if(y==z) cnt++;
      if(cnt==1) ans+=6;
      else if(cnt==2) ans += 3;
      else ans += 1;

    }
  }
}

cout<<ans<<endl;


  return 0;
}
 
0