結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
ankiganbaro
|
| 提出日時 | 2019-03-17 22:58:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 726 bytes |
| コンパイル時間 | 527 ms |
| コンパイル使用メモリ | 73,692 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-08 01:33:33 |
| 合計ジャッジ時間 | 21,794 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 TLE * 1 -- * 9 |
ソースコード
#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;
}
ankiganbaro