#include<bits/stdc++.h>
using namespace std;
int board[1000][1000];
void chess(int x,int y,int z,int size);
int main(int argc,const char *argv[])
{
int n;
int size;
int i,j;
//cout<<"输入2^n * 2^n的棋盘参数n:";
cin>>n;
size=pow(2,n);
chess(1,1,1,size);
for(i=1;i<=pow(2,n);i++)
{
for(j=1;j<=pow(2,n);j++)
{
if(board[i][j]==1)
{
cout<<"p";
}
else if(board[i][j]==0)
{
cout<<"n";
}
}
cout<<endl;
}
return 0;
}
void chess(int x,int y,int z,int size)
{
int half;
if(size==1)
{
board[x][y]=z;
return;
}
half=size/2;
chess(x,y,z,half);
chess(x,y+half,z,half);
if(z==1){
chess(x+half,y,0,half);
}
else{
chess(x+half,y,1,half);
}
chess(x+half,y+half,z,half);
}
#include<bits/stdc++.h>
using namespace std;
#define N 20002
char a[N],b[N];
int f[N][N];
int main()
{
int i,j;
int lena,lenb;
cin>>a+1>>b+1;
lena=strlen(a+1);
lenb=strlen(b+1);
for(i=1;i<=lena;i++)
{
for(j=1;j<=lenb;j++)
{
if(a[i]==b[j])
{
f[i][j]=f[i-1][j-1] + 1;
}
else
f[i][j]=max(f[i-1][j], f[i][j-1]);
}
}
cout<<f[lena][lenb];
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int n,x[100];
int f(int L,int R)
{
int i,j;
if(L>R)
{
for(j=1;j<=n;j++)
cout<<x[j]<<' ';
cout<<endl;
}
for(i=L;i<=R;i++)
{
swap(x[i],x[L]);
f(L+1,R);
swap(x[L],x[i]);
}
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
x[i]=i;
f(1,n);
return 0;
}
03-05
741
05-26
1万+
01-18
1799
11-17
443
08-15
506