#include <iostream>
using namespace std;
unsigned short tot;
void Hanoi(int n, char A, char B, char C) {
++tot;
if(n==1) {
cout<<A<<"->"<<C<<'/';
return;
}
Hanoi(n-1,A,C,B);
cout<<A<<"->"<<C<<'/';
Hanoi(n-1,B,A,C);
}
int main() {
int n;
cin>> n;
Hanoi(n,'A','B','C');
cout<<'\n'<<tot<<'\n';
return 0;
}
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;
const int N = 105;
int a[N][N];
int main() {
int n, x, y,count;
cin>> n;
memset(a,0,sizeof(a));
count=a[x=0][y=n-1]=1;
while (count<n*n) {
while (x+1<n && !a[x+1][y]) a[++x][y]= ++count;
while (y-1>=0&&!a[x][y- 1]) a[x][--y]= ++count;
while (x-1>=0&&!a[x-1][y]) a[--x][y]= ++count;
while (y+1<n &&!a[x][y+1]) a[x][++y]= ++count;
}
for (x=0; x<n; x++) {
for (y=0; y<n; y++) {
cout<<setw(5)<<a[x][y];
}
cout<<endl;
}
return 0;
}
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;
string s;
int main() {
int k;//限制输入0<=k<26
cin>>k>>s;
int n=s.length();
for (int i=0; i<n; i++) {
if (s[i]<='Z'&&s[i]+k>'Z')
s[i]=(s[i]+k)%'Z'+'A'-1;
else if ('A'<=s[i]&&s[i] <='Z')
s[i]+=k;
}
char pre;
int st=-1;
for (int i=0; i<n; i++) {
if(s[i]<'A'||s[i]>'Z') {
if (st==-1) {
st=i;
pre=s[i];
} else {
char tmp=s[i];
s[i]=pre;
pre=tmp;
}
}
}
if(st !=-1)
s[st]=pre;
cout<<s<<endl;
return 0;
}
#include <iostream>
#include <cstring>
# include <queue>
using namespace std;
const int N=105;
int a[N][N];
int in[N],s[N];
int n,m,u,v;
void Topo() {
queue<int> q;
int cnt;
for(int i=1; i<=n; i++)
if(___(1)___)
q.push(i);
while(!q.empty()) {
int cur = q.front();
q.pop();
s[cnt++]=___(2)___;
for (int i=1; i<=n; i++) {
if (___(3)___) {
___(4)___;
if (in[i]==0)
q.push(i);
}
}
}
}
int main() {
memset(in,0,sizeof(in));
memset(a, 0,sizeof(a));
cin>>n>>m;
for (int i=0; i<m; i++) {
cin>>u>>v;
in[v]++;
___(5)___;
}
Topo();
for (int i=0; i<n; i++) {
if (i)
cout<<' ';
cout<<s[i];
}
cout<<endl;
return 0;
}
#include <iostream>
#include<cmath>
using namespace std ;
bool Place(int k,int i,int * x) {
for (int j=0; j<k; j++)
if ((x[j]==i)||___(1)___)
return false;
return true;
}
void NQueens(int k, int n, int *x) {
for (int i=0; i<n; i++) {
if (Place(k,i,x)) {
___(2)___;
if(___(3)___) {
for (int j=0; j<n; j++) cout<<x[j]<<" ";
cout<< endl;
}
else {
___(4)___;
}
}
}
}
int main() {
int x[8];
for (int i=0; i<8; i++)x[i]=-1;
___(5)___;
return 0;
}