提出 #41810914


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
long long lowbit(long long x) { return x&-x; }
int main()
{
	int t;
	cin>>t;
	while(t-->0)
	{
		long long x;
		scanf("%lld", &x);
		while(x&&__builtin_popcountl(x)<3) --x;
		while(x&&__builtin_popcountl(x)>3) x-=lowbit(x);
		printf("%lld\n", x ? x : -1);
	}
	return 0;
}

提出情報

提出日時
問題 B - Exactly Three Bits
ユーザ LingChen
言語 C++ (GCC 9.2.1)
得点 400
コード長 331 Byte
結果 AC
実行時間 54 ms
メモリ 3664 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   11 |   scanf("%lld", &x);
      |   ~~~~~^~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 1
AC × 13
セット名 テストケース
Sample 00-sample-001.txt
All 00-sample-001.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt
ケース名 結果 実行時間 メモリ
00-sample-001.txt AC 7 ms 3616 KiB
01-001.txt AC 48 ms 3564 KiB
01-002.txt AC 47 ms 3644 KiB
01-003.txt AC 47 ms 3580 KiB
01-004.txt AC 31 ms 3592 KiB
01-005.txt AC 36 ms 3540 KiB
01-006.txt AC 48 ms 3640 KiB
01-007.txt AC 47 ms 3592 KiB
01-008.txt AC 43 ms 3580 KiB
01-009.txt AC 38 ms 3584 KiB
01-010.txt AC 38 ms 3600 KiB
01-011.txt AC 46 ms 3640 KiB
01-012.txt AC 54 ms 3664 KiB