結果
| 問題 | No.3276 Make Smaller Popcount | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2025-09-20 13:23:22 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 584 bytes | 
| コンパイル時間 | 324 ms | 
| コンパイル使用メモリ | 41,656 KB | 
| 実行使用メモリ | 7,720 KB | 
| 最終ジャッジ日時 | 2025-09-20 13:23:28 | 
| 合計ジャッジ時間 | 5,135 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | RE * 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 < n; 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;
}
            
            
            
        