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