結果

問題 No.2795 Perfect Number
ユーザー tobbie
提出日時 2024-06-29 22:47:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 402 bytes
コンパイル時間 1,457 ms
コンパイル使用メモリ 165,856 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-06-29 22:47:22
合計ジャッジ時間 5,256 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 1 TLE * 1 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
using ll = long long int;

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  ll n2 = N * 2;
  ll k = 1;
  while (n2 > 0) {
    if (N % k == 0) {
      n2 -= k + N / k;
      ans += k + N / k;
    }
    k++;
  }
  if (ans == N * 2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
0