結果
問題 |
No.800 四平方定理
|
ユーザー |
|
提出日時 | 2019-03-17 22:52:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 671 bytes |
コンパイル時間 | 1,603 ms |
コンパイル使用メモリ | 166,760 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-07-08 01:21:28 |
合計ジャッジ時間 | 5,594 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 10 TLE * 1 -- * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define sorted(a) sort(a.begin(), a.end()); typedef long long unsigned int ll; const long mod = 1e9 + 7; int main(void) { #ifdef DEBUG freopen("input.txt", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(0); long N, D; cin >> N >> D; long long w, x, y, z, n, ans; ans = 0; for (x=1; x<=N; x++) { for (y=1; y<=N; y++) { for (z=1; z<=N; z++) { n = x * x + y * y + z * z; if (n > D) { w = sqrt(n - D); if (w > N) break; if (n - w * w == D) { ans++; } } } } } cout << ans << endl; return 0; }