結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
rhincodon66
|
| 提出日時 | 2019-03-17 22:33:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 542 bytes |
| コンパイル時間 | 1,666 ms |
| コンパイル使用メモリ | 168,212 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-07-08 00:37:52 |
| 合計ジャッジ時間 | 5,627 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 10 TLE * 1 -- * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,d;cin >> n >> d;
vector<bool> a(n*n+1);
for(int i=1;i*i<=n*n;++i){
a.at(i*i)=true;
}
ll ans=0;
for(int x=1;x<=n;++x){
for(int y=1;y<=n;++y){
for(int z=1;z<=n;++z){
int k=x*x+y*y+z*z-d;
if(k>0 && k<=n*n && a.at(k)) ans++;
}
}
}
cout << ans << endl;
}
rhincodon66