Pagini recente » Cod sursa (job #915970) | Cod sursa (job #2326395) | Cod sursa (job #2403565) | Cod sursa (job #3005185) | Cod sursa (job #1706808)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("xormax.in");
ofstream g("xormax.out");
int main()
{
int n, smax = 0, k, p, x[2001] = {0}, s, in , stop;
f >> n;
for(k = 1; k <= n; k++)
{
f >> a;
x[k] = x[k - 1] ^ a;
}
for(k = 1; k <= n - 1; k++)
for(p=k;p<=n;p++)
{s=x[p]^x[k-1];
if(s>smax){smax=s;in=k;stop=p;}
else if(s==smax &&p<stop){smax=s;in=k;stop=p;}
}
g<<smax<<' '<<in<<' '<<stop;
return 0;
}