結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2019-03-17 21:58:31 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 668 bytes |
コンパイル時間 | 1,411 ms |
コンパイル使用メモリ | 159,344 KB |
実行使用メモリ | 34,432 KB |
最終ジャッジ日時 | 2024-07-07 22:38:43 |
合計ジャッジ時間 | 2,514 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>#include <unordered_set>using namespace std;#define ll long long#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)int main() {cin.tie(0);ios::sync_with_stdio(false);cout<<setprecision(std::numeric_limits<float>::max_digits10);ll N,D;cin>>N>>D;vector<int> xy_ans(8000000+1);repeat(x,1,N+1) {repeat(y,1,N+1) {xy_ans[x*x+y*y]++;}}ll ans=0;repeat(z,1,N+1) {repeat(w,1,N+1) {ll c=D+w*w-z*z;if(c>=0) {ans+=xy_ans[c];}}}cout << ans << endl;return 0;}