Created
October 16, 2013 01:22
-
-
Save cocodrips/7001229 to your computer and use it in GitHub Desktop.
SRM594 div2 250
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FoxAndClassroom { | |
public String ableTo(int n, int m) { | |
boolean[][] seated = new boolean[n][]; | |
for (int i = 0; i < seated.length; i++) { | |
seated[i] = new boolean[m]; | |
} | |
int r = 0; | |
int c = 0; | |
seated[r][c] = true; | |
for (int i = 1; i < n * m; i++) { | |
r = (r + 1) % n; | |
c = (c + 1) % m; | |
if (seated[r][c]) { | |
return "Impossible"; | |
} | |
} | |
return "Possible"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment