Pagini recente » Cod sursa (job #1026528) | Cod sursa (job #2341846) | Cod sursa (job #3153479) | Cod sursa (job #3130465) | Cod sursa (job #1706899)
#include <fstream>
using namespace std;
const int NMAX = 100001;
int N, a[NMAX], x[NMAX], smax = 0, nr, i, j, p1, p2;
int main()
{
ifstream f("xormax.in");
ofstream g("xormax.out");
f >> N;
for(i = 1; i <= N; i++)
{
f >> a[i];
// x[i] = x[i - 1] ^ a;
}
for(i = 1; i <= N; i++)
{
nr = 0;
for(j = i; j >= 1; j--)
{
nr ^= a[j];
if(nr > smax)
{
smax = nr;
p1 = i;
p2 = j;
}
}
}
g << smax << ' ' << p1 << ' ' << p2;
f.close();
g.close();
return 0;
}