All pastes #2094008 Raw Edit

Stuff

public text v1 · immutable
#2094008 ·published 2011-11-12 18:06 UTC
rendered paste body
class GBI {
	public int algo(int a, int b) {
		int p = 0;
		int c = 0;
		int d = 1;
		int x;
		int y;
		int i = 0;
		while((a > 0) || (b > 0) || (c > 0)) {
			x = a % 2;
			y = b % 2;
			if((x == 1) ^ (y == 1) ^ (c == 1)) {
				p = p + d;
			}
			if(x == 1 && y == 1) c = 1;
			if(x == 1 && c == 1) c = 1;
			if(y == 1 && c == 1) c = 1;
			d = 2 * d;
			a = a / 2;
			b = b / 2;
			i++;
		}
		return p;
	}

	public static void main(String [] args)	{
		GBI gbi = new GBI();
		System.out.println(gbi.algo(2, 2));
	}
}