結果

問題 No.2795 Perfect Number
ユーザー kentikenti
提出日時 2024-06-28 21:38:12
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 539 bytes
コンパイル時間 681 ms
コンパイル使用メモリ 81,264 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-28 21:38:14
合計ジャッジ時間 1,579 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;

ll N;

int main() {
    cin >> N;
    int ct1 = 0, ct2 = 0;
    while (N % 2 == 0) {
        N /= 2;
        ct1++;
    }
    ll m = N;
    N++;
    while (N % 2 == 0) {
        N /= 2;
        ct2++;
    }
    if (ct1 + 1 != ct2 || N != 1) {
        cout << "No" << endl;
        return 0;
    }
    for (ll i = 2; i * i <= m; i++) {
        if (m % i == 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}
0