結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
leaf_1415
|
| 提出日時 | 2019-03-17 21:32:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 66 ms / 2,000 ms |
| コード長 | 486 bytes |
| コンパイル時間 | 369 ms |
| コンパイル使用メモリ | 59,008 KB |
| 実行使用メモリ | 67,360 KB |
| 最終ジャッジ日時 | 2024-07-07 20:49:54 |
| 合計ジャッジ時間 | 2,153 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long
using namespace std;
llint n, d;
llint cnt[16000005];
int main(void)
{
cin >> n >> d;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
cnt[i*i+j*j]++;
}
}
//sort(vec.begin(), vec.end());
llint ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
llint x = d - (i*i-j*j);
if(x < 0) continue;
ans += cnt[x];
}
}
cout << ans << endl;
return 0;
}
leaf_1415