結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
やむなく
|
| 提出日時 | 2019-03-17 22:15:29 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 601 bytes |
| 記録 | |
| コンパイル時間 | 1,229 ms |
| コンパイル使用メモリ | 187,592 KB |
| 実行使用メモリ | 57,344 KB |
| 最終ジャッジ日時 | 2026-03-29 15:16:05 |
| 合計ジャッジ時間 | 21,088 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 TLE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
typedef long long LL;
typedef long double LD;
int main(){
int n,d;
cin >> n >> d;
map<int,int> mp;
for(int i=1;i<=n;i++){
for(int j=i+1;j<=n;j++){
mp[i*i+j*j]+=2;
}
}
for(int i=1;i<=n;i++) mp[2*i*i]++;
LL ans=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
auto itr=mp.find(i*i-j*j+d);
if(itr!=mp.end()) ans+=itr->second;
}
}
cout << ans << endl;
return 0;
}
やむなく