結果
| 問題 | No.800 四平方定理 |
| コンテスト | |
| ユーザー |
LaFolia13
|
| 提出日時 | 2019-03-17 23:30:41 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 676 bytes |
| 記録 | |
| コンパイル時間 | 1,550 ms |
| コンパイル使用メモリ | 171,960 KB |
| 実行使用メモリ | 241,292 KB |
| 最終ジャッジ日時 | 2024-07-08 05:34:01 |
| 合計ジャッジ時間 | 11,324 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | AC * 7 WA * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;
#define BE(x) x.begin(), x.end()
const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;
int main(){
int N, D;
cin >> N >> D;
int ans = 0;
vector<vector<P>> ok(N*N*2+1);
for(int i = 1; i <= N; i++)
for(int j = i; j <= N; j++)
ok[i*i+j*j].push_back(P(i,j));
for(int i = 1; i <= N; i++)
for(int j = 1; j <= N; j++){
int check = D - (j*j - i*i);
if(check < 0 || check > N*N)
break;
for(auto &x : ok[check]){
if(x.first == x.second)
ans++;
else
ans += 2;
}
}
cout << ans << endl;
return 0;
}
LaFolia13