Friday, October 5, 2007

Wythoff's Game

This one is not there in UVa online judge . Hope it works !
____________________________________________________________________
Question: Wythoff's Queen Game
____________________________________________________________________
#include "iostream.h"
#include "math.h"

int main() {
int n, x, y, small, big, diff;
float phi = (sqrt(5) + 1)/2;
cin >> n >> x >> y;
x--;
y = n - y;
small = (x < y)?x:y;
big = x + y - small;
diff = floor(small / phi);
if(small + diff + 1 == big) cout << "2\n";
else cout << "1\n";
return 0;
}

____________________________________________________________________

No comments:

Contributors