結果

問題 No.1450 nahco314's First Problem
ユーザー QCFium
提出日時 2021-03-31 14:21:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 308 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 165,264 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-08 14:13:15
合計ジャッジ時間 3,262 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int64_t x;
	std::cin >> x;
	for (int64_t i = std::max<int64_t>(1, x - 60); i <= x + 60; i++) {
		if ((i ^ __builtin_popcountll(i)) == x) {
			printf("%" PRId64 "\n", i);
			return 0;
		}
	}
	puts("-1");
	
	return 0;
}
0