提出 #48356115


ソースコード 拡げる

// LUOGU_RID: 139068336
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define File(filename) freopen(filename ".in","r",stdin),freopen(filename ".out","w",stdout)

#ifdef EXODUS
	#define Debug(...) fprintf(stderr,__VA_ARGS__)
#else
	#define Debug(...) 0
#endif

//=========================================================================================================
// Something about IO

template<typename T>
void read(T &x){
	x=0;T flg=1;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')flg=-1;ch=getchar();}
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	x*=flg;
}
template<typename T,typename... Args>
void read(T &x,Args &...args){read(x),read(args...);}

//=========================================================================================================
// Define the global variables here.

bool membg=0;
ll n;
bool memed=0;

//=========================================================================================================
// Code here.

void solve(){
	read(n);
	if(n<7)return printf("-1\n"),void();
	while(__builtin_popcountll(n)<3)n--;
	while(__builtin_popcountll(n)>3)n&=(n-1);
	printf("%lld\n",n);
	return;
}


//=========================================================================================================

int main(){
	Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
	int timbg=clock();
	int T=1;read(T);
	while(T--)solve();
	int timed=clock();
	Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
	fflush(stdout);
	return 0;
}

提出情報

提出日時
問題 B - Exactly Three Bits
ユーザ EXODUS
言語 C++ 17 (gcc 12.2)
得点 400
コード長 1772 Byte
結果 AC
実行時間 25 ms
メモリ 3816 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
   18 |         #define Debug(...) 0
      |                            ^
Main.cpp:58:9: note: in expansion of macro ‘Debug’
   58 |         Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
      |         ^~~~~
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
   18 |         #define Debug(...) 0
      |                            ^
Main.cpp:63:9: note: in expansion of macro ‘Debug’
   63 |         Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
      |         ^~~~~
Main.cpp:59:13: warning: unused variable ‘timbg’ [-Wunused-variable]
   59 |         int timbg=clock();
      |             ^~~~~
Main.cpp:62:13: warning: unused variable ‘timed’ [-Wunused-variable]
   62 |         int timed=clock();
      |             ^~~~~

ジャッジ結果

セット名 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 1 ms 3804 KiB
01-001.txt AC 20 ms 3808 KiB
01-002.txt AC 21 ms 3816 KiB
01-003.txt AC 21 ms 3676 KiB
01-004.txt AC 11 ms 3664 KiB
01-005.txt AC 13 ms 3744 KiB
01-006.txt AC 19 ms 3812 KiB
01-007.txt AC 22 ms 3580 KiB
01-008.txt AC 20 ms 3812 KiB
01-009.txt AC 14 ms 3660 KiB
01-010.txt AC 14 ms 3744 KiB
01-011.txt AC 20 ms 3680 KiB
01-012.txt AC 25 ms 3736 KiB