結果

問題 No.3276 Make Smaller Popcount
ユーザー kotatsugame
提出日時 2025-09-21 12:11:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 334 bytes
コンパイル時間 557 ms
コンパイル使用メモリ 61,752 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-21 12:11:32
合計ジャッジ時間 4,680 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;cin>>T;
	for(;T--;)
	{
		int N;cin>>N;
		if(__builtin_popcount(N)==1)cout<<"-1\n";
		else
		{
			int i=0;
			while(!(N>>i&1))i++;
			i++;
			while(!(N>>i&1))i++;
			cout<<(1<<i)-(N&(1<<i)-1)<<"\n";
		}
	}
}
0