1 solutions
-
0
#include<stdio.h> #include<string.h> const int N = 10 + 5; int count, n, vis[N]; void dfs(int p, int m) { if (m == n){ count++; return ; } vis[p] = 2; for(int i=1;i<=9;i++){ if (vis[i] == 1){ if ((vis[(p + i) / 2] == 0 || vis[(p + i) / 2] == 1) && (p + i == 10 || ((p == 1 && i == 7) || (p == 7 && i == 1)) || ((p == 1 && i == 3) || (p == 3 && i == 1)) || ((p == 3 && i == 9) || (p == 9 && i == 3)) || ((p == 7 && i == 9) || (p == 9 && i == 7)))) continue; else dfs(i, m + 1); } } vis[p] = 1; } int main() { scanf("%d",&n); for(int i=1;i<=n;i++){ int t; scanf("%d",&t); vis[t]=1; } for(int i=1;i<=9;i++){ if(vis[i]==1){ dfs(i,1); } } if(!count)printf("加油华为加油china\n"); else printf("%d\n",count); return 0; }
Information
- ID
- 6702
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 9
- Tags
- (None)
- # Submissions
- 7
- Accepted
- 5
- Uploaded By