結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-20 14:45:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 112 ms / 2,000 ms |
コード長 | 545 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 55,628 KB |
実行使用メモリ | 65,920 KB |
最終ジャッジ日時 | 2024-09-19 00:38:46 |
合計ジャッジ時間 | 3,625 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <iostream> using namespace std; #define INF 8000001 int N, D; int LEFT[INF]; int RIGHT[INF]; int main(){ cin >> N >> D; for(int i = 0; i < INF; ++i){ LEFT[i] = 0; RIGHT[i] = 0; } for(int x = 1;x <= N; ++x){ for(int y = 1; y <= N; ++y){ LEFT[x*x+y*y]++; } } for(int z = 1;z <= N; ++z){ for(int w = 1; w <= N; ++w){ if(w*w-z*z +D >0){ RIGHT[w*w - z*z + D]++; } } } int ans = 0; for(int i = 0; i < INF; ++i){ ans += LEFT[i] * RIGHT[i]; } cout << ans << endl; }