QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#585248#9378. Strange BinarykircoAC ✓15ms3608kbC++231.3kb2024-09-23 19:55:252024-09-23 19:55:29

Judging History

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

  • [2024-09-23 19:55:29]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:3608kb
  • [2024-09-23 19:55:25]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define iosy ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
//https://chatgpt.com/c/66f02d83-2dc8-800b-90ae-d1d29088f1d5
//考虑到相邻的两个bit位,大位是小位的两倍,根据这个性质来解题
//https://blog.csdn.net/ccdme/article/details/142459490?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522B30072A1-F1D4-4919-9C5D-4B8978091FEB%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=B30072A1-F1D4-4919-9C5D-4B8978091FEB&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-12-142459490-null-null.142^v100^pc_search_result_base4&utm_term=Strange%20Binary&spm=1018.2226.3001.4187
void solve(){
	int n;cin>>n;
	vector<int> a(32);
	for(int i=0;i<=31;i++){
		a[i]=(n>>i)&1;
	}
	// for(int i=0;i<=31;i++){
	// 	cout<<a[i]<<" ";
	// }
	// cout<<"\n";
	for(int i=0;i<31;i++){
		if(a[i]==1&&a[i+1]==0){
			a[i]=-1,a[i+1]=1;
		}
	}
	bool ok=0;
	for(int i=0;i<31;i++){
		if(a[i]==0&&a[i+1]==0)ok=1;
	}
	if(ok)cout<<"NO\n";
	else{
		cout<<"YES\n";
		for(int i=0;i<4;i++){
			for(int j=0;j<8;j++){
				cout<<a[i*8+j]<<" ";
			}
			cout<<"\n";
		}
	}
}

signed main()
{
	iosy;
	int _t=1;
	cin>>_t;
	while(_t--){
		solve();
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3528kb

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: 0
Accepted
time: 15ms
memory: 3540kb

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 
YES
0 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 
NO
YES
1 -1 -1 -1 -1 -1 1 1 
-1...

result:

ok Accepted! (10000 test cases)

Extra Test:

score: 0
Extra Test Passed