提示:普及-(很简单的),求人帮助
查看原帖
提示:普及-(很简单的),求人帮助
836448
stylus楼主2025/1/19 10:40

对于每次的答案

可不可以算作 12n/211\longrightarrow 2^n/2-1 为前半部分,2n22n/22^n-2\longrightarrow 2^n/2 算作后半部分。
当然,要补充一些东西。

具体分成5部分

输出 0012n/211\longrightarrow 2^n/2-12n12^n-12n22n/22^n-2\longrightarrow 2^n/200
每行格式为:n位的2进制,再通过0='O'1='X',来转换。

20分的史山:

#include<bits/stdc++.h>
#define int long long
using namespace std;
void read(int &x){
	x=0;bool f=0;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-')f=1;
		ch=getchar();
	}do{x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}while(ch>='0'&&ch<='9');
	x=f?-x:x;
}
int n;
void c(int x){
	for(int i=n-1;i>=0;i--)cout<<((1<<i)&x?"X":"O");
	cout<<endl;return;
}
signed main(){
	read(n);
	for(int i=0;i<(1<<(n-1));i++)c(i);
	c((1<<n)-1);
	for(int i=(1<<n)-2;i>=(1<<(n-1));i--)c(i);
	c(0);
	return 0;
}
/*
OOO
OXO
OXX
OOX
XOX
XXX
XXO
XOO
OOO

000 0
001 1
010 2
011 3
111 7
110 6
101 5
100 4
*/
2025/1/19 10:40
加载中...