11219 - How old are you?

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

Moderator: Board moderators

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

Re: 11219 - How old are you?

Post by brianfry713 » Tue May 21, 2013 2:49 am

Doesn't match the sample I/O
Check input and AC output for thousands of problems on uDebug!

mobarak.islam
New poster
Posts: 38
Joined: Wed Dec 05, 2012 11:29 pm

Re: 11219 - How old are you?

Post by mobarak.islam » Tue May 21, 2013 3:18 pm

@ brianfry713 : thanks for your reply. I checked all sample I/O and it is matched. Would you please mention which one is not match?

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

Re: 11219 - How old are you?

Post by brianfry713 » Tue May 21, 2013 9:45 pm

Check input and AC output for thousands of problems on uDebug!

mobarak.islam
New poster
Posts: 38
Joined: Wed Dec 05, 2012 11:29 pm

Re: 11219 - How old are you?

Post by mobarak.islam » Wed May 22, 2013 9:38 am

@ brianfry713 : I think there are some problem in this online compiler(https://ideone.com/raVomD)
I got wrong output for all of my code in this site. Even output is not same for all time in this online compiler :(

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

Re: 11219 - How old are you?

Post by brianfry713 » Wed May 22, 2013 11:09 pm

I think there is a problem with your code.
Change line 11 from:
scanf("%d%/%d%/%d%d%/%d%/%d",&Dc,&Mc,&Yc,&Db,&Mb,&Yb);
to:
scanf("%d/%d/%d%d/%d/%d",&Dc,&Mc,&Yc,&Db,&Mb,&Yb);
Check input and AC output for thousands of problems on uDebug!

mobarak.islam
New poster
Posts: 38
Joined: Wed Dec 05, 2012 11:29 pm

Re: 11219 - How old are you?

Post by mobarak.islam » Thu May 23, 2013 9:59 am

@ brianfry713: Finally I got AC :) Thank You very much .

mobarak.islam
New poster
Posts: 38
Joined: Wed Dec 05, 2012 11:29 pm

Re: 11219 - How old are you?

Post by mobarak.islam » Thu May 23, 2013 10:35 am

.

marufsharif
New poster
Posts: 6
Joined: Sun Jul 21, 2013 1:36 pm

[11219 - How old are you?] Wrong Answer!! Plz help me

Post by marufsharif » Sun Jul 21, 2013 1:44 pm

my code is below:

Code: Select all

#include <stdio.h>

int main(void)
{
	int tC, i, cDD, cMM, cYY, bDD, bMM, bYY, day, month, year;

	scanf("%d", &tC);

	for(i=0; i<tC; i++)
	{
		scanf("%d/%d/%d", &cDD, &cMM, &cYY);
		scanf("%d/%d/%d", &bDD, &bMM, &bYY);

		if(cDD<bDD)
		{
			day = (cDD+30) - bDD;
			cMM--;
		}
		else
			day = cDD - bDD;

		if(cMM<bMM)
		{
			month = (cMM+12) - bMM;
			cYY--;
		}
		else
			month = cMM - bMM;

		year = cYY - bYY;

		if(year<0)
			printf("Case #%d: Invalid birth date\n", i+1);
		else if(year>130)
			printf("Case #%d: Check birth date\n", i+1);
		else
			printf("Case #%d: %d\n",i+1, year);
	}
	printf("\n");

	return 0;
}

aybek
New poster
Posts: 19
Joined: Fri Jul 19, 2013 10:25 am
Contact:

Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Post by aybek » Sun Jul 21, 2013 8:56 pm

marufsharif, correctly asked question is half of answer!
noone will be able to help you if they will not understand the problem,
that's why please, write about what your program does and define
the problem. Thx ).

marufsharif
New poster
Posts: 6
Joined: Sun Jul 21, 2013 1:36 pm

Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Post by marufsharif » Mon Jul 22, 2013 10:29 am

@aybek
Thanks for your reply.
My problem is that my code [for 11219 - How old are you? problem] properly generate output as the problem is required.
But I'm failed every time when i submit my code, and i got wrong answer many times. :cry:
I get WA when i tried to print Last line with space and without space in my code.
I'm also test my code with various type of Data, as long as i observe, my code is correct. So why i get WA. :-?
Please, help me for finding wrong with my code.

aybek
New poster
Posts: 19
Joined: Fri Jul 19, 2013 10:25 am
Contact:

Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Post by aybek » Mon Jul 22, 2013 5:33 pm

marufsharif wrote: I get WA when i tried to print Last line with space and without space in my code.
If the output data of your program is valid but wasn't print in correct format, you won't
get WA, you will get PE (Presentation Error)

try to give this input for your program:
1

05/01/2013
06/02/2012

your program output is:
Case #1: Invalid birth date
but it is not true answer. ). Sorry for my english.

aybek
New poster
Posts: 19
Joined: Fri Jul 19, 2013 10:25 am
Contact:

Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Post by aybek » Mon Jul 22, 2013 8:13 pm

Code: Select all

#include <stdio.h>

struct date {
	int day, month, year;
};

int main()
{
	int Casenum;
	scanf("%d", &Casenum);

	struct date curr;
	struct date born;
	struct date diff;

	int i;
	for (i = 1; i <= Casenum; i++)
	{
		scanf("%d/%d/%d", &curr.day, &curr.month, &curr.year);
		scanf("%d/%d/%d", &born.day, &born.month, &born.year);

		diff.year = curr.year-born.year;
		diff.month = curr.month-born.month;
		diff.day = curr.day-born.day;

		if (diff.year >= 0) {
			if (diff.month < 0)
				diff.year--;
			else if (diff.month == 0)
				if (diff.day < 0)
					diff.year--;
		}

		printf("Case #%d: ", i);
		if (diff.year < 0)
			printf("Invalid birth date\n");
		else if (diff.year > 130)
			printf("Check birth date\n");
		else
			printf("%d\n", diff.year);
	}

	return 0;
}
I didn't use structures, too. But understood that they makes code
more simple and easy to read. My advice for you: use structures.
Good luck in programming! :wink:

marufsharif
New poster
Posts: 6
Joined: Sun Jul 21, 2013 1:36 pm

Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Post by marufsharif » Wed Jul 24, 2013 5:52 pm

@aybek
Thank you for your quick response. :D

pinku.duet
New poster
Posts: 1
Joined: Tue Jan 01, 2013 7:41 pm

Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Post by pinku.duet » Sun Nov 10, 2013 4:40 pm

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
using namespace std;
int main()
{
int cases,dd1,dd2,mm1,mm2,yy1,yy2,d,m,y,test=0;
cin>>cases;
while(cases != 0)
{
test++;
printf("\n");
scanf("%d/%d/%d%d/%d/%d",&dd1,&mm1,&yy1,&dd2,&mm2,&yy2);
if(dd1<dd2)
{
dd1 = dd1 + 30;
mm1--;
}
if(mm1<mm2)
{
mm1 = mm1 + 12;
yy1--;
}
d = dd1 - dd2;
m = mm1 - mm2;
y = yy1 - yy2;
if(y < 0)
{
printf("Case #%d: Invalid birth date\n",test);
}
else if(y > 130)
{
printf("Case #%d: Check birth date\n",test);
}
else
{
printf("Case #%d: %d\n",test,y);
}
cases--;
}
return 0;
}

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

Re: [11219 - How old are you?] Wrong Answer!! Plz help me

Post by brianfry713 » Wed Nov 13, 2013 1:25 am

The output is comprised of one line for each input data set
Don't print extra blank lines.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 112 (11200-11299)”