結果
問題 |
No.3276 Make Smaller Popcount
|
ユーザー |
![]() |
提出日時 | 2025-09-20 13:24:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 273 ms |
コンパイル使用メモリ | 41,800 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-20 13:24:44 |
合計ジャッジ時間 | 4,874 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%d", &tn); | ~~~~~^~~~~~~~~~~ main.cpp:31:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | scanf("%d", &n); | ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3276.cc: No.3276 Make Smaller Popcount - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int BN = 30; /* typedef */ /* global variables */ int bs[BN]; /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d", &n); int k = 0; for (int i = 0; i < BN; i++) if ((n >> i) & 1) bs[k++] = i; if (k >= 2) { int x = (1 << bs[1]) - (1 << bs[0]); printf("%d\n", x); } else puts("-1"); } return 0; }