#include "stdio.h" using namespace std; int count = 0; int total[93];//存储king[i] int king[9];//k[i]表示第i行的皇后在king[i]列 int calculate(){ int sum = 0; for (int i = 1; i <= 8; ++i) { sum = sum*10+king[i]; } return sum; } bool kingJudge(int x,int y){ for (int i = 1; i < x; ++i) { if(king[i] == y) return false; if(i + king[i] == x+y) return false; if(i - king[i] == x-y) return false; } return true; } void kingDFS(int row){ if(row == 9){ int sum = calculate(); ++count; total[count] = sum; return; } else{ for (int i = 1; i <= 8; ++i) { if(kingJudge(row,i)){ king[row] = i; kingDFS(row+1); king[row] = 0; } } } } int main(){ int pos; kingDFS(1); while (scanf("%d",&pos)!=EOF){ printf("%d\n",total[pos]); } }