結果
| 問題 | No.680 作れる数 | 
| コンテスト | |
| ユーザー |  merom686 | 
| 提出日時 | 2018-04-27 23:02:40 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 732 bytes | 
| コンパイル時間 | 755 ms | 
| コンパイル使用メモリ | 73,328 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-27 22:10:11 | 
| 合計ジャッジ時間 | 1,418 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    int b = 0;
    if (n <= 1) {
        b = 1;
    } else {
        for (int k = 2; k < 30; k++) {
            int s = (1 << k) - 1;
            if (s > n) continue;
            int t = 1 << (k - 1);
            if (s == n) b = 1;
            while (t - 1 > 0) {
                s += t - 1;
                if (s > n) {
                    s -= t - 1;
                }
                if (s == n) b = 1;
                t /= 2;
            }
        }
    }
    cout << (b ? "YES" : "NO") << endl;
    return 0;
}
            
            
            
        