結果
問題 | No.800 四平方定理 |
ユーザー | koyopro |
提出日時 | 2020-01-07 00:04:45 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,733 bytes |
コンパイル時間 | 1,431 ms |
コンパイル使用メモリ | 159,532 KB |
実行使用メモリ | 143,348 KB |
最終ジャッジ日時 | 2023-08-14 23:01:18 |
合計ジャッジ時間 | 31,516 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
5,080 KB |
testcase_01 | AC | 16 ms
6,348 KB |
testcase_02 | AC | 11 ms
5,652 KB |
testcase_03 | AC | 13 ms
5,720 KB |
testcase_04 | AC | 11 ms
5,348 KB |
testcase_05 | AC | 13 ms
5,712 KB |
testcase_06 | AC | 19 ms
6,856 KB |
testcase_07 | AC | 17 ms
6,152 KB |
testcase_08 | AC | 17 ms
6,860 KB |
testcase_09 | AC | 17 ms
6,416 KB |
testcase_10 | AC | 994 ms
73,840 KB |
testcase_11 | AC | 972 ms
82,364 KB |
testcase_12 | AC | 1,105 ms
80,968 KB |
testcase_13 | AC | 885 ms
77,092 KB |
testcase_14 | AC | 900 ms
82,232 KB |
testcase_15 | AC | 1,080 ms
81,740 KB |
testcase_16 | AC | 887 ms
83,228 KB |
testcase_17 | AC | 877 ms
83,144 KB |
testcase_18 | AC | 1,193 ms
82,764 KB |
testcase_19 | AC | 1,115 ms
82,876 KB |
testcase_20 | AC | 1 ms
4,376 KB |
testcase_21 | AC | 2 ms
4,376 KB |
testcase_22 | AC | 1,177 ms
83,132 KB |
testcase_23 | TLE | - |
testcase_24 | AC | 1,895 ms
143,044 KB |
testcase_25 | TLE | - |
testcase_26 | AC | 2 ms
4,376 KB |
testcase_27 | AC | 2 ms
4,376 KB |
testcase_28 | AC | 1,906 ms
142,368 KB |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | AC | 1,892 ms
133,068 KB |
testcase_32 | TLE | - |
ソースコード
#include "bits/stdc++.h" using namespace std; #define int long long #define FOR(i, a, b) for(int i=(a);i<(b);i++) #define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--) #define REP(i, n) for(int i=0; i<(n); i++) #define RREP(i, n) for(int i=(n-1); i>=0; i--) #define ALL(a) (a).begin(),(a).end() #define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end()); #define CONTAIN(a, b) find(ALL(a), (b)) != (a).end() #define array2(type, x, y) array<array<type, y>, x> #define vector2(type) vector<vector<type> > #define out(...) printf(__VA_ARGS__) int dxy[] = {0, 1, 0, -1, 0}; void solve(); signed main() { #if DEBUG std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); #endif cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; } /*================================*/ int N,D,x,y,z,w; struct XY { int x,y; XY() {}; XY(int x, int y): x(x), y(y) {}; }; void solve() { cin>>N>>D; // x >= y >= z; map<int, vector<XY>> M; FOR(x,1,N+1) FOR(y,1,x+1) { int s = x*x + y*y; M[s].push_back(XY(x,y)); } int ans = 0; FOR(w,1,N+1) { int ma = w*w+D; for(z=1; z<=N+1 && z*z*3<=ma; z++) { int t = ma - z*z; if (t <= 0) continue; auto it = M.find(t); if (it == M.end()) continue; for (auto xy : it->second) { if (xy.y < z) continue; vector<int> a{xy.x,xy.y,z}; UNIQUE_SORT(a) switch(a.size()) { case 1: ans += 1; break; case 2: ans += 3; break; default: ans += 6; break; } } } } cout << ans << endl; }