結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
LaFolia13
|
| 提出日時 | 2019-03-17 23:34:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 570 ms / 2,000 ms |
| コード長 | 696 bytes |
| コンパイル時間 | 1,329 ms |
| コンパイル使用メモリ | 172,080 KB |
| 実行使用メモリ | 241,152 KB |
| 最終ジャッジ日時 | 2024-07-08 05:47:03 |
| 合計ジャッジ時間 | 9,344 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#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)
break;
if(check > N*N*2)
continue;
for(auto &x : ok[check]){
if(x.first == x.second)
ans++;
else
ans += 2;
}
}
cout << ans << endl;
return 0;
}
LaFolia13