11219 - How old are you?

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

Moderator: Board moderators

Postby hamedv » Sat Jul 21, 2007 6:43 pm

can u pm me your full code???
hamedv
Learning poster
 
Posts: 98
Joined: Mon May 07, 2007 8:30 am

Postby Pedro » Sat Jul 21, 2007 6:55 pm

Full code

Code: Select all
#include <stdio.h>
#include <stdlib.h>

int casos;
int i;
int dia,mes,ano;
int dia2,mes2,ano2;
int resultado;

int VerificaBissexto(int b){
 if (b%100!=0){
    if (b%4==0){
       return 1;           
    }else{
          return 0;
          }             
 }else{
       if (b%400==0){
          return 1;             
       }else{
             return 0;
             }
       }   
   
}

void CalculaAnos(int d1,int d2,int m1,int m2,int a1,int a2,int numCaso){
     int m,a,d;
   
    if (a1==a2){
       if (m1>=m2){
          if (m2==m1){     
             if (d1>=d2){
                   printf("Case #%d: 0",numCaso);
                   return;         
             }else{
                   printf("Case #%d: Invalid birth date",numCaso);
                   return;
                   }                 
          }else{
                printf("Case #%d: 0",numCaso);
                return;
                }
         
       }else{
             printf("Case #%d: Invalid birth date",numCaso);
             return;
             }           
    }else{
          if (a1<a2){
             printf("Case #%d: Invalid birth date",numCaso);
             return;     
          }else{
                if (m1>m2){
                   a=a1-a2;       
                }else{
                      if (m1==m2){
                         if (VerificaBissexto(a2)==1){
                           if (VerificaBissexto(a1)==0){
                            if ((d2==29)&&(d1==28)){
                               printf("Case #%d: 0",numCaso);
                               return;                     
                            }
                           }else{
                                 if (d1<d2){
                                    a=a1-a2-1;
                                    printf("Case #%d: %d",numCaso,a);
                                    return;         
                                 }
                                 }                       
                         }
                         
                           if (m2>m1){
                              a=a1-a2-1;
                              printf("Case #%d: %d",numCaso,a);
                              return;         
                           }       
                                   if (d2<d1){
                                      a=a1-a2;       
                                   }else{
                                         if (d2!=d1){
                                            a=a1-a2-1;
                                         }else{
                                               a=a1-a2;
                                         }
                                   }
                               
                                         
                      }
                     
                      }
               
                }
         
         
          }
         
  if (a<=130){       
    printf("Case #%d: %d",numCaso,a);
    }else{
          printf("Case #%d: Check birth date",numCaso,a);
          }
   
}

int main(){
    scanf("%d",&casos);
    for (i=1;i<=casos;i++){
        printf("\n");
        scanf("%d/%d/%d",&dia,&mes,&ano);
        scanf("%d/%d/%d",&dia2,&mes2,&ano2);
        CalculaAnos(dia,dia2,mes,mes2,ano,ano2,i);
       
        }
   
   
}
[/code]
Pedro
New poster
 
Posts: 5
Joined: Fri Jul 20, 2007 5:18 pm

Greater than 130?

Postby himanshu » Mon Oct 29, 2007 1:45 pm

Code: Select all
1

01/01/2031
02/01/1900


Shouldn't the above output "Check birth date" because the age is greater than 130 even though it is not 131 years.

The judge accepts 130.

Thank You,
HG
himanshu
New poster
 
Posts: 17
Joined: Mon May 15, 2006 12:24 pm
Location: Hyderabad, India

Wrong Answer 11219!!!

Postby mukit » Wed Nov 21, 2007 1:18 pm

Can someone help me to find the bug ?
I'm getting wrong answer with this simple problem...
Code: Select all
Removed after AC

Thank's a lot himanshu. I got AC.
Last edited by mukit on Thu Nov 22, 2007 6:12 pm, edited 1 time in total.
mukit
New poster
 
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Location: Dhaka , Bangladesh

Re: Wrong Answer 11219!!!

Postby himanshu » Wed Nov 21, 2007 2:00 pm

Did you try this test case posted earlier in this thread?

Code: Select all
1

01/02/1984
02/01/1984


Thank You,
HG
himanshu
New poster
 
Posts: 17
Joined: Mon May 15, 2006 12:24 pm
Location: Hyderabad, India

Postby IRA » Mon Dec 03, 2007 6:25 am

I try all case in this thread
but still got WA
Who can help me?

My code as follow
Code: Select all
Removed after AC

Thank's a lot helloneo
Last edited by IRA on Mon Dec 03, 2007 11:50 am, edited 2 times in total.
IRA
Learning poster
 
Posts: 82
Joined: Sat Jan 07, 2006 6:52 am

Postby helloneo » Mon Dec 03, 2007 7:50 am

Try this case..

Code: Select all
1

01/01/2004
01/02/2004


My output..

Code: Select all
Case #1: Invalid birth date


:-)
helloneo
Guru
 
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Re: 11219 - How old are you?

Postby kbr_iut » Thu Sep 18, 2008 3:08 pm

thanx shiplu,,,,U r really boss.
I got AC.
Actually I am a great stupid.
Last edited by kbr_iut on Fri Sep 26, 2008 1:09 am, edited 1 time in total.
It is tough to become a good programmer.
It is more tough to become a good person.
I am trying both...............................
User avatar
kbr_iut
Experienced poster
 
Posts: 103
Joined: Tue Mar 25, 2008 11:00 pm
Location: IUT-OIC, DHAKA, BANGLADESH

Re: 11219 - How old are you?

Postby shiplu_1320 » Mon Sep 22, 2008 10:23 am

Kabir, try this,
input:
Code: Select all
2
28/2/2001
1/3/2001

29/2/2000
1/3/2000

output should be
Code: Select all
Case #1: Invalid birth date
Case #2: Invalid birth date

Good luck
A learner......
shiplu_1320
New poster
 
Posts: 32
Joined: Sat Dec 29, 2007 9:08 pm
Location: CSEDU , Dhaka

Re: 11219 - How old are you?

Postby bleedingeyes » Mon Sep 22, 2008 6:07 pm

i got invalid for those input
but not AC yet
Code: Select all
//got AC
Last edited by bleedingeyes on Tue Sep 23, 2008 1:43 pm, edited 1 time in total.
wanna be notorious....
bleedingeyes
New poster
 
Posts: 9
Joined: Thu Aug 21, 2008 3:08 am
Location: IUT

Re: 11219 - How old are you?

Postby shiplu_1320 » Mon Sep 22, 2008 10:03 pm

you can try this
Code: Select all
1
2/10/2000
2/11/1999

Output should be
Code: Select all
Case #1: 0

Good luck :D
A learner......
shiplu_1320
New poster
 
Posts: 32
Joined: Sat Dec 29, 2007 9:08 pm
Location: CSEDU , Dhaka

Re: 11219 - How old are you?

Postby bleedingeyes » Tue Sep 23, 2008 1:42 pm

thanks . i got AC now
wanna be notorious....
bleedingeyes
New poster
 
Posts: 9
Joined: Thu Aug 21, 2008 3:08 am
Location: IUT

Re: 11219 - How old are you?

Postby Obaida » Wed Jan 07, 2009 9:30 am

Some one please help me to get Accepted.
I got WA for this problem.
Code: Select all
removed
Last edited by Obaida on Sat Jan 10, 2009 7:58 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper
 
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 11219 - How old are you?

Postby shiplu_1320 » Wed Jan 07, 2009 11:12 am

You are not printing newline in the output properly. check out it .........
Good luck :)
A learner......
shiplu_1320
New poster
 
Posts: 32
Joined: Sat Dec 29, 2007 9:08 pm
Location: CSEDU , Dhaka

Re: 11219 - How old are you?

Postby Obaida » Sat Jan 10, 2009 8:15 am

Edited but still wA!!!
Code: Select all
removed
Last edited by Obaida on Sat Jan 10, 2009 11:50 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper
 
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

PreviousNext

Return to Volume CXII

Who is online

Users browsing this forum: No registered users and 1 guest