10783 - Odd Sum

All about problems in Volume 107. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

RoniphpBB
New poster
Posts: 10
Joined: Sat Feb 09, 2013 11:22 am

Odd sum

Post by RoniphpBB » Fri May 31, 2013 1:56 am

AC
Last edited by RoniphpBB on Sat Jun 01, 2013 2:08 pm, edited 1 time in total.

User avatar
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

Re: Odd sum

Post by sohel » Fri May 31, 2013 3:43 pm

What is your output for the following input:

2 10


and look for threads related to your problem by using the search option on the top-right. Make your post in an existing thread - don't create a new one!

RoniphpBB
New poster
Posts: 10
Joined: Sat Feb 09, 2013 11:22 am

Re: Odd sum

Post by RoniphpBB » Sat Jun 01, 2013 1:59 pm

Many many thanks to you Brother sohel

rloursua
New poster
Posts: 4
Joined: Tue Feb 11, 2014 5:52 pm

Re: 10783- Why WA??

Post by rloursua » Thu Feb 13, 2014 1:18 pm

Could somebody help me? why do i get getting WA

Code: Select all

#include <iostream>
using namespace std;

int main()
{
	int test=0;
	int a,b;
	cin >> test;
	for( int i=0; i<test ;i++)
	{
		cin >> a >> b;
		int j=a;
		int sum=0;
		for(j=a;j<=b;j++)
		{
			if(j%2)
				sum=sum+j;
		}
		if(i!=test-1)
			cout << "Case " << i+1 << ": " << sum << endl;
		else
			cout << "Case " << i+1 << ": " << sum;	
	}
	return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10783- Why WA??

Post by brianfry713 » Fri Feb 14, 2014 12:31 am

Print a newline char at the end of the last line.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 107 (10700-10799)”