暴力枚举
1 #include <iostream>
2 #include <vector>
3 #include <string>
4
5 using namespace std;
6
7 class FoxAndClassroom{
8 public:
9 string ableTo(int n , int m){
10 for(int i = 0 ; i < n ; ++ i ){
11 for(int j = 0 ; j < m; ++ j ){
12 vector<vector<bool> > visitFlag(n,vector<bool>(m,false));
13 int kx = i ,ky = j,count = 0;
14 while(!visitFlag[kx][ky]){
15 visitFlag[kx][ky] = true;
16 kx = (kx+1)%n;
17 ky = (ky+1)%m;
18 count++;
19 }
20 if(count == m*n) return "Possible";
21 }
22 }
23 return "Impossible";
24 }
25
26 };