結果
問題 | No.800 四平方定理 |
ユーザー |
|
提出日時 | 2019-04-18 05:18:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 92 ms / 2,000 ms |
コード長 | 582 bytes |
コンパイル時間 | 1,600 ms |
コンパイル使用メモリ | 167,456 KB |
実行使用メモリ | 65,912 KB |
最終ジャッジ日時 | 2024-09-22 08:45:13 |
合計ジャッジ時間 | 3,671 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for (int i=0;i<(n);i++) #define REP2(i,m,n) for (int i=m;i<(n);i++) typedef long long ll; const ll M = 2000 * 2000; ll N, D; ll cnt[M*2+1]; void solve() { cin >> N >> D; ll ans = 0; REP2 (z, 1, N+1) REP2 (w, 1, N+1) cnt[z*z-w*w+M] += 1; REP2 (x, 1, N+1) REP2 (y, 1, N+1) { if (D - x*x - y*y < -M) continue; if (D - x*x - y*y > M) continue; ans += cnt[D-x*x-y*y+M]; } cout << ans << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); solve(); }