結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2019-03-17 22:51:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 541 bytes |
| コンパイル時間 | 1,854 ms |
| コンパイル使用メモリ | 200,792 KB |
| 最終ジャッジ日時 | 2025-01-06 23:12:57 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 TLE * 3 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
signed main(){
Int n,d;
cin>>n>>d;
unordered_map<Int, Int> cnt;
for(Int i=1;i<=n;i++)
for(Int j=1;j<=n;j++)
cnt[i*i+j*j]++;
Int ans=0;
for(Int i=1;i<=n;i++){
for(Int j=1;j<=n;j++){
Int v=i*i-j*j+d;
ans+=cnt[v];
}
}
cout<<ans<<endl;
return 0;
}
beet