Pagini recente » Cod sursa (job #748602) | Borderou de evaluare (job #289311) | Cod sursa (job #2426608) | Cod sursa (job #364860) | Cod sursa (job #532594)
Cod sursa(job #532594)
#include<fstream>
using namespace std;
int v[100000];
int n;
int main()
{
ifstream in("xormax.in");
in>>n;
for(int i = 0; i < n; i++)
in>>v[i];
in.close();
int now = 0;
int start = 0, end = 0;
int max = 0;
for(int c = 0; c < n - 1; c++)
{
now = v[c];
for(int i = c + 1; i < n; i++)
{
now ^= v[i];
if(now > max)
{
max = now;
start = c;
end = i;
}
}
}
ofstream out("xormax.out");
out<<max<<" "<<start + 1 <<" "<<end + 1;
out.close();
}