Pagini recente » Cod sursa (job #1603557) | Cod sursa (job #926978) | Cod sursa (job #2845429) | Cod sursa (job #1445255) | Cod sursa (job #1703706)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("xormax.in");
ofstream g("xormax.out");
int n, nr, i, v[2001], smax, j, x[2001], p1, p2;
int main()
{
f >> n;
for (i = 1; i <= n; i++) {
f >> v[i];
x[i] = x[i - 1] ^ v[i];
}
smax = 0;
for (i = 1; i <= n; i++)
for (j = i; j <= n; j++)
{
nr = x[j] ^ x[i - 1];
if (nr > smax) {
smax = nr;
p1 = i;
p2 = j;
}
}
g << smax << ' ' << p1 << ' ' << p2;
return 0;
}