結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-17 22:32:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 926 bytes |
| コンパイル時間 | 476 ms |
| コンパイル使用メモリ | 71,244 KB |
| 実行使用メモリ | 65,792 KB |
| 最終ジャッジ日時 | 2024-07-08 00:36:02 |
| 合計ジャッジ時間 | 7,529 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 RE * 13 |
ソースコード
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"
#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")
#define MAX 4100000
int temp[MAX*2];
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout<<fixed<<setprecision(10);
int N, D, count = 0;
cin>>N>>D;
for(int i = 1; i <= N; i++){
for(int j = 1; j <= N; j++){
// cout<<j*j-i*i<<" ++ "<<endl;
temp[j*j-i*i+MAX]++;
}
}
for(int i = 1; i <= N; i++){
for(int j = i; j <= N; j++){
int t = i*i+j*j-D;
// cout<<t<<endl;
if(temp[t+MAX]){
// cout<<i<<" "<<j<<" "<<temp[t+MAX]<<endl;
if(i == j)count += temp[t+MAX];
else count += temp[t+MAX]*2;
}
}
}
cout<<count<<endl;
return 0;
}