Page 6 of 8

Re: 11219 - How old are you?

Posted: Tue May 21, 2013 2:49 am
by brianfry713
Doesn't match the sample I/O

Re: 11219 - How old are you?

Posted: Tue May 21, 2013 3:18 pm
by mobarak.islam
@ brianfry713 : thanks for your reply. I checked all sample I/O and it is matched. Would you please mention which one is not match?

Re: 11219 - How old are you?

Posted: Tue May 21, 2013 9:45 pm
by brianfry713

Re: 11219 - How old are you?

Posted: Wed May 22, 2013 9:38 am
by mobarak.islam
@ 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 :(

Re: 11219 - How old are you?

Posted: Wed May 22, 2013 11:09 pm
by brianfry713
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);

Re: 11219 - How old are you?

Posted: Thu May 23, 2013 9:59 am
by mobarak.islam
@ brianfry713: Finally I got AC :) Thank You very much .

Re: 11219 - How old are you?

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

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

Posted: Sun Jul 21, 2013 1:44 pm
by marufsharif
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;
}

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

Posted: Sun Jul 21, 2013 8:56 pm
by aybek
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 ).

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

Posted: Mon Jul 22, 2013 10:29 am
by marufsharif
@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.

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

Posted: Mon Jul 22, 2013 5:33 pm
by aybek
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.

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

Posted: Mon Jul 22, 2013 8:13 pm
by aybek

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:

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

Posted: Wed Jul 24, 2013 5:52 pm
by marufsharif
@aybek
Thank you for your quick response. :D

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

Posted: Sun Nov 10, 2013 4:40 pm
by pinku.duet
#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;
}

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

Posted: Wed Nov 13, 2013 1:25 am
by brianfry713
The output is comprised of one line for each input data set
Don't print extra blank lines.