A. Paritytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given an integer nn
(n≥0n≥0
) represented with kk
digits in base (radix) bb
. So,n=a1⋅bk−1+a2⋅bk−2+…ak−1⋅b+ak.n=a1⋅bk−1+a2⋅bk−2+…ak−1⋅b+ak.
For example, if b=17,k=3b=17,k=3
and a=[11,15,7]a=[11,15,7]
then n=11⋅172+15⋅17+7=3179+255+7=3441n=11⋅172+15⋅17+7=3179+255+7=3441
.Determine whether nn
is even or odd.InputThe first line contains two integers bb
and kk
(2≤b≤1002≤b≤100
, 1≤k≤1051≤k≤105
) — the base of the number and the number of digits.The second line contains kk
integers a1,a2,…,aka1,a2,…,ak
(0≤ai<b0≤ai<b
) — the digits of nn
.The representation of nn
contains no unnecessary leading zero. That is, a1a1
can be equal to 00
only if k=1k=1
.OutputPrint “even” if nn
is even, otherwise print “odd”.You can print each letter in any case (upper or lower).ExamplesInputCopy13 3
3 2 7
OutputCopyeven
InputCopy10 9
1 2 3 4 5 6 7 8 9
OutputCopyodd
InputCopy99 5
32 92 85 74 4
OutputCopyodd
InputCopy2 2
1 0
OutputCopyeven
NoteIn the first example, n=3⋅132+2⋅13+7=540n=3⋅132+2⋅13+7=540
, which is even.In the second example, n=123456789n=123456789
is odd.In the third example, n=32⋅994+92⋅993+85⋅992+74⋅99+4=3164015155n=32⋅994+92⋅993+85⋅992+74⋅99+4=3164015155
is odd.In the fourth example n=2n=2
.
#include <iostream>
#include <bits/stdc++.h>
#include <string.h>
#include <math.h>
using namespace std;
long long int n[100010];
int main()
{
long long int a,b,c,i,sum=0;
cin >> a >> b;
for(i=b; i>0; i--)
{
cin >> c;
if(a%2!=0)
{
if(i==1)
{
if(c%2!=0)
{
n[i]=1;
}
else
{
n[i]=2;
}
}
else
{
if(c%2!=0)
{
n[i]=1;
}
else
{
n[i]=2;
}
}
}
else
{
if(i==1)
{
if(c%2!=0)
{
n[i]=1;
}
else
{
n[i]=2;
}
}
else
{
n[i]=2;
}
}
}
for(i=b; i>0; i--)
{
sum=sum+n[i];
}
if(sum%2==0)
{
cout << "even";
}
else
{
cout << "odd";
}
return 0;
}