I beg you, please, help me.... :(

The problem : http://codeforces.com/problemset/problem/4/A

my solution :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

using namespace std;

int main(void)
{
	int w=(1<=w<=100);

	cin >> w;

	if (w%2==0)
		cout << "YES";
	else
		cout << "NO";

	return 0;
}


but when everyitme i submit, and the site test my code, then the site always say "Wrong answer on test 5". Test 5 maybe means line 5 (?). Is there anything wrong with my solution ? Thanks.
This line is not valid c++ syntax (and doesn't make any sense)
int w=(1<=w<=100);

Do you want w to be a random number between 1 and 100? If so the code is:
int w = rand()%100;

EDIT: I see in the problem-text that it says 1<=w<=100. That just means that the input your code will be getting will be between 1 and 100 inclusive.
Last edited on
In line 7, you only need int w;
The problem described w as an integer between 1 and 100 for your own personal information; it doesn't affect the coding at all, and you don't need to initialize w here, since the cin in the next line does so. Other than that your code looks fine.
Last edited on
Also, your code doesn't correctly answer the problem. In addition to checking w%2==0, you also need to check that the two parts are even :)
Read the problem carefully.
Test the limits. By instance, ┬┐which should be the output for `w=2'?
Topic archived. No new replies allowed.