結果

問題 No.2392 二平方和
ユーザー a01sa01to
提出日時 2023-07-30 00:13:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 1,594 ms
コンパイル使用メモリ 192,676 KB
最終ジャッジ日時 2025-02-15 21:02:49
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

inline bool is_sqr(int x) {
  int ok = 0, ng = 3e4;
  while (ng - ok > 1) {
    int mid = (ok + ng) / 2;
    if (mid * mid <= x) ok = mid;
    else
      ng = mid;
  }
  return ok * ok == x;
}

int main() {
  int p;
  cin >> p;
  for (int i = 1; i * i < p; i++) {
    int j2 = p - i * i;
    if (is_sqr(j2)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}
0