Created
February 24, 2012 05:22
-
-
Save basicxman/1897963 to your computer and use it in GitHub Desktop.
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
| #include <iostream> | |
| #include <math.h> | |
| using namespace std; | |
| bool isCrystal(int m, int x, int y) { | |
| int curX = x; | |
| int curY = y; | |
| for (int curM = m; curM > 0; curM--) { | |
| int majorSize = pow(5, curM) / 5; | |
| int mX = curX / majorSize; | |
| int mY = curY / majorSize; | |
| // In solid major cells. | |
| if (mY == 0 && (mX == 1 || mX == 2 || mX == 3)) return true; | |
| if (mY == 1 && mX == 2) return true; | |
| // Out of range major cell. | |
| if (mY == 4 || mY == 3 || mX == 0 || mX == 4) return false; | |
| if (mY == 2 && (mX == 1 || mX == 3)) return false; | |
| curX -= majorSize * mX; | |
| curY -= majorSize * mY; | |
| } | |
| return false; | |
| } | |
| int main(int argc, char **argv) { | |
| freopen("s3.in", "r", stdin); | |
| int n; | |
| scanf("%d\n", &n); | |
| for (int i = 0; i < n; i++) { | |
| int m, x, y; | |
| scanf("%d %d %d\n", &m, &x, &y); | |
| if (isCrystal(m, x, y)) { | |
| cout << "crystal" << endl; | |
| } else { | |
| cout << "empty" << endl; | |
| } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment