結果

問題 No.2795 Perfect Number
ユーザー kenti
提出日時 2024-06-28 21:28:52
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 720 ms
コンパイル使用メモリ 80,648 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-06-28 21:28:59
合計ジャッジ時間 7,371 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 1 TLE * 2 -- * 17
権限があれば一括ダウンロードができます

ソースコード

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++;
    }
    for (ll i = 2; i * i <= N; i++) {
        if (N % i == 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    N++;
    while (N % 2 == 0) {
        N /= 2;
        ct2++;
    }
    if (ct1 + 1 == ct2) {
        cout << "Yes" << endl;
    } else
        cout << "No" << endl;
    return 0;
}
0