結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2019-03-17 21:26:41 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 680 bytes |
| コンパイル時間 | 9,226 ms |
| コンパイル使用メモリ | 280,432 KB |
| 最終ジャッジ日時 | 2025-01-06 22:41:37 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 TLE * 2 |
ソースコード
#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;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T,typename U>
using gmap = cc_hash_table<T, U, hash<T> >;
//INSERT ABOVE HERE
signed main(){
int n,d;
cin>>n>>d;
gmap<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