結果
| 問題 | No.3276 Make Smaller Popcount | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-09-19 22:41:11 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 62 ms / 2,000 ms | 
| コード長 | 560 bytes | 
| コンパイル時間 | 3,241 ms | 
| コンパイル使用メモリ | 275,560 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-09-19 22:41:22 | 
| 合計ジャッジ時間 | 6,291 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 28 | 
ソースコード
#include <bits/stdc++.h>
[[nodiscard]] static inline constexpr int_fast32_t solve(const uint_fast32_t N) noexcept
{
	if (std::popcount(N) <= 1) [[unlikely]] return -1;
	uint_fast32_t i = 1;
	for (i = 1; std::popcount(N & ((UINT32_C(1) << i) - 1)) < 2; ++i);
	return (UINT32_C(1) << i) - (N & ((UINT32_C(1) << i) - 1));
}
int main()
{
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	
	uint_fast32_t T;
	std::cin >> T;
	for (uint_fast32_t i = 0; i != T; ++i)
	{
		uint_fast32_t N;
		std::cin >> N;
		std::cout << solve(N) << '\n';
	}
	return 0;
}
            
            
            
        