結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-17 23:48:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 777 ms / 2,000 ms |
| コード長 | 390 bytes |
| コンパイル時間 | 597 ms |
| コンパイル使用メモリ | 75,752 KB |
| 実行使用メモリ | 19,792 KB |
| 最終ジャッジ日時 | 2024-07-08 07:13:57 |
| 合計ジャッジ時間 | 11,548 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,d;
vector<int>a;
main()
{
cin>>n>>d;
for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)a.push_back(i*i-j*j);
sort(a.begin(),a.end());
int ans=0;
for(int i=1;i<=n;i++)for(int j=i;j<=n;j++)
ans+=(upper_bound(a.begin(),a.end(),i*i+j*j-d)-lower_bound(a.begin(),a.end(),i*i+j*j-d))*(1+(i<j));
cout<<ans<<endl;
}