結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2020-11-28 16:40:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 484 bytes |
コンパイル時間 | 2,202 ms |
コンパイル使用メモリ | 193,560 KB |
最終ジャッジ日時 | 2025-01-16 09:27:35 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <stdio.h>#include <bits/stdc++.h>using namespace std;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf 1000000000000000000int main(){int N,D;cin>>N>>D;vector<long long> cnt(10000000,0LL);for(int i=1;i<=N;i++){for(int j=1;j<=N;j++){cnt[i*i+j*j]++;}}long long ans = 0LL;for(int i=1;i<=N;i++){for(int j=1;j<=N;j++){int t = i*i-j*j+D;if(t<0)continue;ans += cnt[t];}}cout<<ans<<endl;return 0;}