Cod sursa(job #208520)

Utilizator mordredSimionescu Andrei mordred Data 17 septembrie 2008 00:42:52
Problema Xor Max Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <stdio.h>
#define max(a,b) ((a>b)?a:b)
#define xxor(a,b) ((a==b)?0:1)
#define nmax 100001

int n,c[nmax],cs[nmax];
bool a[nmax][22],s[nmax][39];
int i,j,x,maxs,maxi,maxj;

int main(){
 freopen("xormax.in","r",stdin);
 freopen("xormax.out","w",stdout);
 
 scanf("%d",&n);
 
 for(i=1;i<=n;++i)
    {
    scanf("%d",&x);
    if(!x) c[i]=1;
    while(x)
        {
        a[i][++c[i]] = x % 2;
        x /= 2;
        }
    }
 
 for(i=1;i<=n;++i)
    {
    x = max(c[i],cs[i-1]);
    for(j=1;j<=x;++j)
        s[i][j] = xxor(s[i-1][j],a[i][j]);
    cs[i] = x;
    }
 
 /*
 for(i=1;i<=n;++i){printf("%2d : ",i);
        for(j=1;j<=cs[i];++j)
            printf("%d",s[i][j]);printf("\n");}
 */
 
 return 0;    
}