結果
| 問題 | No.680 作れる数 | 
| コンテスト | |
| ユーザー |  ats5515 | 
| 提出日時 | 2018-04-27 22:55:37 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 727 bytes | 
| コンパイル時間 | 590 ms | 
| コンパイル使用メモリ | 81,564 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-27 22:08:34 | 
| 合計ジャッジ時間 | 1,281 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 | 
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int calcs(int t) {
	int res = 0;
	while (t > 0) {
		res += t;
		t /= 2;
	}
	return  res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	if (N == 0) {
		cout << "YES" << endl;
		return  0;
	}
	int u = (int)1000000000;
	cerr << calcs(u) << endl;
	int d = 0;
	while (u - d > 1) {
		int m = (u + d) / 2;
		if (calcs(m) >= N) {
			u = m;
		}
		else {
			d = m;
		}
	}
	if (calcs(u) == N) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}
            
            
            
        