結果
問題 | No.2392 二平方和 |
ユーザー |
![]() |
提出日時 | 2023-07-28 21:27:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 3,134 bytes |
コンパイル時間 | 1,753 ms |
コンパイル使用メモリ | 197,208 KB |
最終ジャッジ日時 | 2025-02-15 20:00:15 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include "bits/stdc++.h"using namespace std;// #define ONLINE_JUDGE#ifndef ONLINE_JUDGE#include "cp-library/debug.h"#else#define dump(...) true#endifnamespace util {using ll = long long;using vl = std::vector<long long>;using pl = std::pair<long long, long long>;constexpr long long kInf = std::numeric_limits<long long>::max() / 8;constexpr long long kMax = std::numeric_limits<long long>::max();template <typename T, typename U>inline bool UpdateMax(T &x, const U &y) {if (x < y) {x = y;return true;}return false;}template <typename T, typename U>inline bool UpdateMin(T &x, const U &y) {if (x > y) {x = y;return true;}return false;}// verifiedinline long long Pow(long long x, long long n) {assert(n >= 0);if (x == 0) return 0;long long res = 1LL;while (n > 0) {if (n & 1) {assert(x != 0 && std::abs(res) <= kMax / std::abs(x));res = res * x;}if (n >>= 1) {assert(x != 0 && std::abs(x) <= kMax / std::abs(x));x = x * x;}}return res;}// verifiedinline long long Mod(long long n, const long long m) {// returns the "arithmetic modulo"// for a pair of integers (n, m) with m != 0, there exists a unique pair of// integer (q, r) s.t. n = qm + r and 0 <= r < |m| returns this rassert(m != 0);if (m < 0) return Mod(n, -m);if (n >= 0)return n % m;elsereturn (m + n % m) % m;}inline long long Quotient(long long n, long long m) {// returns the "arithmetic quotient"assert((n - Mod(n, m)) % m == 0);return (n - Mod(n, m)) / m;}inline long long DivFloor(long long n, long long m) {// returns floor(n / m)assert(m != 0);if (m < 0) {n = -n;m = -m;}if (n >= 0)return n / m;else if (n % m == 0)return -(abs(n) / m);elsereturn -(abs(n) / m) - 1;}inline long long DivCeil(long long n, long long m) {// returns ceil(n / m)assert(m != 0);if (n % m == 0)return DivFloor(n, m);elsereturn DivFloor(n, m) + 1;}template <typename T>inline T Sum(const std::vector<T> &vec) {return std::accumulate(vec.begin(), vec.end(), T(0));}} // namespace utilusing namespace util;template <typename T>class Set : public std::set<T> {public:bool Contains(const T &x) { return (*this).find(x) != (*this).end(); }T Min() {assert(!(*this).empty());return *(*this).begin();}T Max() {assert(!(*this).empty());auto it = (*this).end();--it;return *it;}void PopFront() {assert(!(*this).empty());erase((*this).begin());}void PopBack() {assert(!(*this).empty());auto it = (*this).end();(*this).erase(--it);}};void solve() {ll p;cin >> p;Set<ll> se;for (ll i = 1; i <= 10000; ++i) {se.insert(i * i);}for (ll i = 1; i <= 10000; ++i) {if (se.Contains(p - i * i)) {cout << "Yes" << '\n';return;}}cout << "No" << '\n';}int main() {std::cin.tie(nullptr);std::ios::sync_with_stdio(false);std::cout << std::fixed << std::setprecision(15);solve();return 0;}