QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#581662#9378. Strange BinaryhuangceWA 11ms3808kbC++171.2kb2024-09-22 13:48:092024-09-22 13:48:10

Judging History

你现在查看的是最新测评结果

  • [2024-09-22 13:48:10]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3808kb
  • [2024-09-22 13:48:09]
  • 提交

answer

/*
* @Author: dsaDadas11
* @Date: 2024-06-27 10:33:26
 * @LastEditTime: 2024-09-22 13:47:25
* @Description: go for it!
*/
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define int ll
using namespace std;
constexpr int N=1e6+7;
constexpr int M=2e3+7;
int n;
int a[37]; // 0-31
int p[37];
void pre()
{
	p[0]=1;
	for(int i=1;i<=32;i++)
	{
		p[i]=p[i-1]*2;
	}
}
void solve()
{
	cin>>n;
	int t=n;
	if(n%4==0)
	{
		cout<<"NO"<<endl;
		return;
	}
	for(int i=0;i<=31;i++) a[i]=1;
	bool flag=0;
	if(n%2==0) flag=1;
	vector<int> v;
	while(n)
	{
		if(n&1) v.push_back(1);
		else v.push_back(0);
		n>>=1;
	}
	while((int)v.size()!=32) v.push_back(0);
	v.push_back(1);
//	for(auto i:v) cout<<i;
//	cout<<endl;
//	reverse(v.begin(),v.end());
	for(int i=0;i<=31;i++)
	{
		a[i]=v[i+1];
	}
	for(int i=0;i<=31;i++)
	{
		if(a[i]==0) a[i]=-1;
	}
	int res=0;
	for(int i=0;i<=31;i++)
	{
		res+=a[i]*p[i];
	}
	if(res!=t)
	{
		cout<<"NO"<<endl;
		return;
	}
	cout<<"YES"<<endl;
	for(int i=0;i<=31;i++)
	{
		cout<<a[i]<<' ';
		if((i+1)%8==0) cout<<endl;
	}
}
signed main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	pre();
	int T=1; cin>>T;
	while(T--){solve();}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3604kb

input:

3
0
3
5

output:

NO
YES
1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 1 
YES
-1 1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 -1 
-1 -1 -1 -1 -1 -1 -1 1 

result:

ok Accepted! (3 test cases)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

2
0
1073741823

output:

NO
YES
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 1 1 1 1 -1 -1 1 

result:

ok Accepted! (2 test cases)

Test #3:

score: -100
Wrong Answer
time: 11ms
memory: 3808kb

input:

10000
324097321
555675086
304655177
991244276
9980291
383616352
1071036550
795625380
682098056
68370721
969101726
685975156
973896269
354857775
196188000
606494155
754416123
467588829
495704303
558090120
618002000
491488050
741575237
9937018
10028830
140094825
652839595
357724903
516690123
817724271...

output:

YES
-1 -1 1 -1 1 -1 -1 1 
-1 1 -1 1 -1 1 -1 1 
-1 -1 -1 1 -1 1 -1 1 
1 -1 -1 1 -1 -1 -1 1 
NO
YES
-1 -1 1 -1 -1 1 -1 1 
1 -1 1 -1 1 -1 1 -1 
-1 -1 1 -1 1 -1 -1 -1 
1 -1 -1 1 -1 -1 -1 1 
NO
YES
1 -1 -1 -1 -1 -1 1 1 
-1 -1 1 -1 -1 1 -1 -1 
-1 -1 1 1 -1 -1 1 -1 
-1 -1 -1 -1 -1 -1 -1 1 
NO
NO
NO
NO
YES
...

result:

wrong answer Jury's answer is YES, but Participant's answer is NO. (test case 10000)