結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 22:41:48 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 482 bytes |
コンパイル時間 | 417 ms |
コンパイル使用メモリ | 61,016 KB |
実行使用メモリ | 34,432 KB |
最終ジャッジ日時 | 2024-07-08 00:55:08 |
合計ジャッジ時間 | 2,614 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include<iostream>#include<vector>#include<algorithm>using namespace std;int main(){long N,D;cin >> N >> D;vector<int> sq(2*N*N,0);for(int y=1;y<=N;y++){for(int z=1;z<=N;z++){sq[y*y+z*z]++;}}long ans = 0;for(long x=1;x<=N;x++){for(long w=1;w<=N;w++){long c = w*w - x*x + D;if(c < 2 || c > 2*N*N) continue;ans += sq[c];}}cout << ans << endl;}