結果
問題 | No.800 四平方定理 |
ユーザー |
![]() |
提出日時 | 2019-03-17 23:28:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 661 bytes |
コンパイル時間 | 1,652 ms |
コンパイル使用メモリ | 171,348 KB |
実行使用メモリ | 241,224 KB |
最終ジャッジ日時 | 2024-07-08 03:25:37 |
合計ジャッジ時間 | 12,146 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 RE * 1 |
other | AC * 27 RE * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; using llong = long long; using ldbl = long double; using P = pair<llong, llong>; #define BE(x) x.begin(), x.end() const llong inf = llong(1e18)+7; const llong mod = 1e9+7; int main(){ int N, D; cin >> N >> D; int ans = 0; vector<vector<P>> ok(N*N*2+1); for(int i = 1; i <= N; i++) for(int j = i; j <= N; j++) ok[i*i+j*j].push_back(P(i,j)); for(int i = 1; i <= N; i++) for(int j = 1; j <= N; j++){ int check = D - (j*j - i*i); if(check < 0) break; for(auto &x : ok[check]){ if(x.first == x.second) ans++; else ans += 2; } } cout << ans << endl; return 0; }