All pastes #984428 Raw Edit

Mine

public text v1 · immutable
·published 2008-04-14 05:54 UTC
rendered paste body
#include<iostream>
using namespace std;
int a1,b1,c1,ares,bres,cres;
int mask[25];
int flag;
void compute(int bitpos,int a,int b,int c){
    int x,y,z,xn,yn,zn;
    if(bitpos == 24){
        ares=a;
        bres=b;
        cres=c;
        flag=1;
    }
    for(int i=0;i<2&&flag!=1;i ++){
        for(int j=0;j<2&&flag!=1;j++){
            for(int k=0;k<2&&flag!=1;k++){
                x=(i<<bitpos)|a;
                y=(j<<bitpos)|b;
                z=(k<<bitpos)|c;
                xn=(y*z)^x;
                yn=(x*z)^y;
                zn=(x*y)^z;
                if((xn&mask[bitpos])==(a1&mask[bitpos])&&(yn&mask[bitpos])==(b1&mask[bitpos])&&(zn&mask[bitpos])==(c1&mask[bitpos]))
                    compute(bitpos+1,x,y,z);
            }
        }
    }
}

int main(){ 
    mask[0] = 1; 
    for(int i=1;i<25;i++)
        mask[i]=mask[i-1]<<1;
    cin>>a1>>b1>>c1; 
    flag=0;
    ares=bres=cres=-1;
    compute(0,0,0,0);
    cout<<ares<<" "<<bres<<" "<<cres<<"\n";
    return 0;
}