結果
問題 | No.800 四平方定理 |
ユーザー | nn1k_ |
提出日時 | 2019-03-17 23:26:14 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,945 bytes |
コンパイル時間 | 930 ms |
コンパイル使用メモリ | 109,332 KB |
実行使用メモリ | 81,572 KB |
最終ジャッジ日時 | 2024-07-08 03:12:38 |
合計ジャッジ時間 | 21,457 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
10,624 KB |
testcase_01 | AC | 19 ms
5,376 KB |
testcase_02 | AC | 13 ms
5,376 KB |
testcase_03 | AC | 14 ms
5,376 KB |
testcase_04 | AC | 12 ms
5,376 KB |
testcase_05 | AC | 15 ms
5,376 KB |
testcase_06 | AC | 21 ms
5,376 KB |
testcase_07 | AC | 18 ms
5,376 KB |
testcase_08 | AC | 17 ms
5,376 KB |
testcase_09 | AC | 20 ms
5,376 KB |
testcase_10 | AC | 1,383 ms
39,680 KB |
testcase_11 | AC | 1,523 ms
44,032 KB |
testcase_12 | AC | 1,515 ms
43,264 KB |
testcase_13 | AC | 1,259 ms
41,344 KB |
testcase_14 | AC | 1,375 ms
44,032 KB |
testcase_15 | AC | 1,567 ms
43,776 KB |
testcase_16 | AC | 1,368 ms
44,416 KB |
testcase_17 | AC | 1,379 ms
44,416 KB |
testcase_18 | AC | 1,718 ms
44,160 KB |
testcase_19 | AC | 1,695 ms
44,288 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 1,792 ms
44,416 KB |
testcase_23 | TLE | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
コンパイルメッセージ
main.cpp: In function 'bool isOK(i64, i64, i64)': main.cpp:96:1: warning: control reaches end of non-void function [-Wreturn-type] 96 | } | ^
ソースコード
#include <iostream> #include <vector> #include <map> #include <unordered_map> #include <limits> #include <algorithm> #include <queue> #include <set> #include <unordered_map> #include <numeric> #include <cmath> #include <iomanip> #include <stack> #include <string> #include <functional> using namespace std; using i64 = long long; using ui64 = unsigned long long; using P = pair<int, int>; constexpr int INF = (1 << 30); constexpr std::int64_t INF64 = (1LL << 60); constexpr int MOD = 1e9 + 7; //constexpr std::int64_t MOD64 = 1e11 + 3; int dx[] = { -1, 0, 1, 0 }; int dy[] = { 0, 1, 0, -1 }; template <typename T, typename U> static inline std::vector<U> makeNdVector(T n, U val) noexcept { static_assert(std::is_integral<T>::value, "[makeNdVector] 1st argument must be an integer type"); return std::vector<U>(std::forward<T>(n), std::forward<U>(val)); } template <typename T, typename ...Args> static inline decltype(auto) makeNdVector(T n, Args... args) noexcept { static_assert(std::is_integral<T>::value, "[makeNdVector] 1st argument must be an integer type"); return std::vector<decltype(makeNdVector(std::forward<Args>(args)...))>(std::forward<T>(n), makeNdVector(std::forward<Args>(args)...)); } template <typename T> void print(vector<T> vec) { for (auto &e : vec) cout << e << " "; cout << endl; } void YES(bool f) { cout << (f ? "YES" : "NO") << endl; } void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; } void yes(bool f) { cout << (f ? "yes" : "no") << endl; } template <typename T> T gcd(T x, T y) { if (x == 0 || y == 0) return 0; T r; while ((r = x % y) != 0) { x = y; y = r; } return y; } template <typename T> T lcm(T x, T y) { if (x == 0 || y == 0) return 0; return (x / gcd(x, y) * y); } int next_combination(int sub) { int x = sub & -sub, y = sub + x; return (((sub & ~y) / x) >> 1) | y; } std::uint64_t combination(int n, int r) { if (n < 0 || r < 0) return 0; if (n < r) return 0; std::uint64_t k = 1; for (std::uint64_t d = 1; d <= r; ++d) { k *= n--; k /= d; } return k; } bool isOK(i64 b, i64 n, i64 key) { i64 sum = 0; while (n > 0) { sum += n % b; n /= b; } if (sum == key) return true; } i64 binary_search(i64 n, i64 key) { i64 left = -1; i64 right = n + 1; while (right - left > 1) { i64 mid = left + (right - left) / 2; long double l = log(n) / log(mid); i64 num = floor(l) + 1; cout << mid << " " << num << endl; num *= (mid - 1); if (num >= key) right = mid; else left = mid; } return right; } signed main() { cin.tie(0); ios::sync_with_stdio(false); using P = pair<int, int>; i64 N, D; cin >> N >> D; map<i64, int> left; for (i64 x = 1; x <= N; ++x) { for (i64 y = 1; y <= N; ++y) { left[x * x + y * y]++; } } i64 ans = 0; for (i64 z = 1; z <= N; ++z) { for (i64 w = 1; w <= N; ++w) { i64 n = z * z - w * w; if (left.count(D - n) == 0) continue; else ans += left[D - n]; } } cout << ans << endl; }