結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 22:15:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,969 ms / 2,000 ms |
コード長 | 601 bytes |
コンパイル時間 | 1,379 ms |
コンパイル使用メモリ | 173,072 KB |
実行使用メモリ | 57,216 KB |
最終ジャッジ日時 | 2024-07-07 23:49:08 |
合計ジャッジ時間 | 21,195 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() #define SP <<" "<< #define MOD 1000000007 #define IINF 1000000000 #define LINF 1000000000000000000 typedef long long LL; typedef long double LD; int main(){ int n,d; cin >> n >> d; map<int,int> mp; for(int i=1;i<=n;i++){ for(int j=i+1;j<=n;j++){ mp[i*i+j*j]+=2; } } for(int i=1;i<=n;i++) mp[2*i*i]++; LL ans=0; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ auto itr=mp.find(i*i-j*j+d); if(itr!=mp.end()) ans+=itr->second; } } cout << ans << endl; return 0; }