結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 21:30:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 578 bytes |
コンパイル時間 | 1,781 ms |
コンパイル使用メモリ | 173,572 KB |
実行使用メモリ | 73,888 KB |
最終ジャッジ日時 | 2024-07-07 20:42:28 |
合計ジャッジ時間 | 27,938 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 TLE * 1 |
other | AC * 14 TLE * 7 -- * 9 |
ソースコード
#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=1;j<=n;j++){ if(i*i-j*j+d>=2) mp[i*i-j*j+d]++; } } 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); if(itr!=mp.end()) ans+=itr->second; } } cout << ans << endl; return 0; }