結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 21:25:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,616 ms / 2,000 ms |
コード長 | 679 bytes |
コンパイル時間 | 2,048 ms |
コンパイル使用メモリ | 220,228 KB |
最終ジャッジ日時 | 2025-01-06 22:38:31 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#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; }