×

# Panel Members

Problem Setter: Suhash
Problem Tester: Editorialist: Sunny Aggarwal
Russian Translator:
Mandarin Translator:
Vietnamese Translator:
Language Verifier:

Cakewalk

# PREREQUISITES:

Simple, Input processing, Basic Maths.

# PROBLEM:

Given a list of integers. We are asked to report whether the number of even integers is more than the number of odd integers or not.

# EXPLANATION

This is a simple problem and can be solved by simply counting the number of even/odd integers.

Basic C++ Code:

int main() {
int n; cin >> n;
int cnt = 0;
for(int i=1; i<=n; i++) {
int x; cin >> x;
if( x % 2 == 0 ) cnt ++;
}
puts( cnt > n - cnt ? "READY FOR BATTLE" : "NOT READY" );
return 0;
}


Basic Java Code:

public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int cnt = 0;
for(int i=1; i<=n; i++) {
int x;
x = sc.nextInt();
if( x % 2 == 0 ) {
cnt ++;
}
}
System.out.println( cnt > n - cnt ? "READY FOR BATTLE" : "NOT READY" );
}


Basic Python Code:

import sys
f = sys.stdin
cnt = 0
A = [int(x) for x in f.readline().split()]
for i in range(0, n):
if A[i] % 2 == 0:
cnt += 1
if cnt > n - cnt:
else:


# TIME COMPLEXITY

$O(N)$

# SPACE COMPLEXITY

$O(1)$

# SIMILAR PROBLEMS

Distinct Codes

Black And White Cells

Chef And Easy Problem

This question is marked "community wiki".

1.7k11630
accept rate: 11%

19.8k350498541

 0 import java.io.*; public class in { public static void main(String args[])throws IOException { BufferedReader buf=new BufferedReader(new InputStreamReader(System.in)); int n,a,i,j=0,c=0; n=Integer.parseInt(buf.readLine()); for(i=0;ib) System.out.println("READY FOR BATTLE"); else System.out.println("NOT READY"); } } answered 22 Mar '16, 15:55 1 accept rate: 0%
 0 import java.io.*; public class in { public static void main(String args[])throws IOException { BufferedReader buf=new BufferedReader(new InputStreamReader(System.in)); int n,a,i,j=0,c=0; n=Integer.parseInt(buf.readLine()); for(i=0;ib) System.out.println("READY FOR BATTLE"); else System.out.println("NOT READY"); } } answered 22 Mar '16, 15:56 1 accept rate: 0%

# include<cstring>

using namespace std; int main() { int n,ev=0,od=0; int a[100]; cin>>n; for(int i=0;i<n;i++) {="" cin="">>a[i]; if(a[i]%2==0) ev++; else od++; } if(ev>od) cout<<"READY FOR BATTLE"; else cout<<"NOT READY"; return 0; }

1
accept rate: 0%

# include<iostream>

using namespace std;

int main()

{

int a[100],n,i,ev,od;

ev=0;

ev=0;

cin>>n;

for(i=0;i<n;i++)

{

cin>>a[i];

}

for(i=0;i<n;i++)

{

if((a[i]%2)==0)

{

ev++;

}

else

{

od++;

}

}

if(ev>od)

{

}

else

{

} return (0);

}

0★vichumon
1
accept rate: 0%

(18 Jul '16, 00:15) 0★

whats wrong with this code? why is it not entering the loop?

# include<stdio.h>

void main() { int N,i,b=0; int A[100]; scanf("%d",&N); for(i=1;i<=N;i++) { scanf("%d",&A[i]); } for(i=1;i<=N;i++) { if(A[i]%2==0) b=b+1; } if(b>N-b) printf(" ready for battle"); else printf("not ready "); }

1
accept rate: 0%

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×15,639
×3,746
×1,173
×170
×52
×1

question asked: 17 Nov '15, 03:12

question was seen: 4,085 times

last updated: 27 Jul '16, 22:19