## 10465 - Homer Simpson

Moderator: Board moderators

Red Scorpion
Experienced poster
Posts: 192
Joined: Sat Nov 30, 2002 5:14 am

### 10465.

Hi, elsa@nnnn
but still crash in this input:
Input:

9 7 6 2
2 5 6
45 23 91
5 9 19

Regards,
RS

elsa@nnnn
New poster
Posts: 5
Joined: Wed May 07, 2003 5:49 pm
I got ac now ,thanks very much

Eric
Learning poster
Posts: 83
Joined: Wed Sep 11, 2002 6:28 pm
Location: Hong Kong
Why the input
9 7 6 2
gives
8
Why there are four integers in the input? And what do they represent?

elsa@nnnn
New poster
Posts: 5
Joined: Wed May 07, 2003 5:49 pm
for the input 9 7 62
you see : 7* 5 + 9 *3 == 62
so the output should be 8

Eric
Learning poster
Posts: 83
Joined: Wed Sep 11, 2002 6:28 pm
Location: Hong Kong
Oh...I misunderstand the input as 9 7 6 2 (four numbers).
My program passes these cases, however it still gets WA
Last edited by Eric on Sat Jan 31, 2004 6:33 am, edited 1 time in total.

elsa@nnnn
New poster
Posts: 5
Joined: Wed May 07, 2003 5:49 pm
I am not familiar with pas code.
the problem is :
when beer needed, you should get the min time ( only time ,not burger number )
else get max burger number.
there is no trick in this problem !

Eric
Learning poster
Posts: 83
Joined: Wed Sep 11, 2002 6:28 pm
Location: Hong Kong
Do you mean that if we must have beer, we only need to minimize the time for beer but don't need to maximize the number of burger?

Learning poster
Posts: 57
Joined: Sun Sep 29, 2002 12:00 pm
Location: in front of the monitor :-)
Contact:
hello.

the problemstatement asks to maximize the number of burgers, after minimizing the time for drinking beer.

ayaw
New poster
Posts: 18
Joined: Fri May 23, 2003 3:52 pm
Contact:
my code giv the same result....
but' i still get WA

here is it:

Code: Select all

``````#include <stdio.h>

main() {
long i,j,m,n,t,max,waste,time;
while( scanf("%ld %ld %ld",&m,&n,&t)!=EOF ) {
max=0;
time=0;
waste=0;
for(i=0;m*i<=t;i++)
for(j=0;m*i+n*j<=t;j++) {
if(m*i+n*j==t && i+j>max) { max=i+j; }
else if(i+j>waste) { waste=i+j; time=m*i+n*j; }
}
if(max==0) printf("%ld %ld\n",waste,t-time);
else printf("%ld\n", max);
}
return 0;
}
``````
peace...

kallal
New poster
Posts: 4
Joined: Wed Jun 11, 2003 7:11 pm
Contact:

### Any Input with beer time? please

My code works with the given inputs but i get WA.
Please someone send some input that will have some time for beer !
Thanks.
Hi to all from Kallal !

Faizur
New poster
Posts: 39
Joined: Fri Jun 06, 2003 3:04 pm
Even though my code works with the sampe i/o and the i/o provided in this page i am getting wa .Here is my code:

Code: Select all

``````#include<stdio.h>
int main()
{
int m,n,t,time;
int n1,n2,m1,m2,p,q,beer;
while(scanf("%d%d%d",&m,&n,&t)==3)
{
beer=t;
m1=m2=0;
if(m==1 || n==1)
{
printf("%d\n",t);
continue;
}
if(n<m)
{
time=m;
m=n;
n=time;
}
p=t/n;
int tag=0;
for(n1=0;n1<=p;n1++)
{
time=t-n1*n;
if(time>=0 && time%m==0)
{
if((n1+time)/m>m1)
{
m1=n1+time/m;
tag=1;
}
}
else if(time>=0 && (time%m)!=0)
{
q=time/m;
if((time-q*m)<beer)
{
m2=n1+q;
beer=time-q*m;
}
else if((time-q)==beer)
if(n1+q>m2)
m2=n1+q;
}
}

if(tag)printf("%d\n",m1);
else printf("%d %d\n",m2,beer);
}

}
``````
where is the fault pls help????

miras
Learning poster
Posts: 98
Joined: Sat Jun 14, 2003 1:45 pm

### 10465 help needed

hello
i tried to solve 10465 and when i solved it i got WA why can anyone help me i tested my program on some tests from ather pages

~~~~~~~~~~~~~~~~~~~~~~~~~~~~
my code
[pascal]
program Homer;
var tab:array[0..10000] of longint;
w,a,m,n,t:longint;

begin

while not eof do
begin
for a:=1 to 10000 do tab[a]:=0;

tab[0]:=1;
w:=t;
for a:=n to t do begin if tab[a-n]<>0 then tab[a]:=tab[a-n]+1; end;
for a:=m to t do begin if tab[a-m]<>0 then tab[a]:=tab[a-m]+1; end;
inc(t);
repeat
dec(t);
until tab[t]<>0;
if w-t<>0 then writeln(tab[t]-1,' ',w-t) else writeln(tab[t]-1);
end;
end.

________________________
thanks

[/pascal]

Zhao Le
Learning poster
Posts: 80
Joined: Mon May 05, 2003 4:09 am
Location: Shanghai,China

### 10465

I have searched the board for test case.

I have successfully passed.(maybe missed some)

I don't know why got TLE.

may someone help or give me some new cases, thanks in advance.

[cpp]#include <iostream.h>

void main()
{
int m,n,t;
while(cin>>m>>n>>t)
{
if(m>n) // exchange to keep m < n
{
int tmp=n;
n=m;
m=tmp;
}
if(t%m==0) cout<<t/m<<endl; // the ideal case,leaves no time
else
{
int i,bears1=0,bears2=0;
for(i=n;i<t;i+=n)
if(i%n==0&&(t-i)%m==0)
{
bears1=i/n+(t-i)/m;
break;
}
for(i=m;i<t;i+=m)
if(i%m==0&&(t-i)%n==0)
{
bears2=i/m+(t-i)/n;
break;
}
if(bears1||bears2) // also the ideal case,leaves no times
{
if(bears1<bears2) // output the max bears
cout<<bears2<<endl;
else
cout<<bears1<<endl;
}
else // no the ideal case, should leave times
{
int bears=t/m;
int times=t%m;
int tmp1=n-m;
int tmp2=n%m;
int i=0;
while(tmp1&&times>=tmp1&&i<bears)
{
times-=tmp1;
i++;
}
while(bears!=t/n&&times>=tmp2)
{
times-=tmp2;
bears=bears-n/m+1;
}
cout<<bears;
if(times)
cout<<' '<<times<<endl;
else
cout<<endl;
}//end else
}//end else
}// end while
}// end main[/cpp]
Last edited by Zhao Le on Fri Aug 01, 2003 11:31 am, edited 1 time in total.
AC makes me feels good,
But WA makes me thinks hard.

miras
Learning poster
Posts: 98
Joined: Sat Jun 14, 2003 1:45 pm
in the end i got AC
_________________
mADE tHE fORcE bE wiTH yOU

eloha
New poster
Posts: 38
Joined: Thu Oct 31, 2002 8:24 am
Location: Taiwan
I got TLE too.
Can anyone help me?
[c]#include <stdio.h>
#include <string.h>
int a[10000];
void main()
{
int t,i,j,k,m,n,temp;

while(scanf("%d %d %d",&m,&n,&t)==3)
{
if(m>n) { temp=m; m=n; n=temp; } /* make sure m<=n */
if(m==1) { printf("%d\n",t); continue; }
if(m>t) { printf("0 %d\n",t); continue; }
memset(a,0,sizeof(a));
a[0]=0;
for(i=m,k=1; i<=t; i+=m)
{
a=k++;
}
k=t/n;
for(i=1; i<=k; i++)
for(j=t-n; j>=0; j--)
{
if(a[j] || j==0)
{
if(a[j]+1>a[j+n])
a[j+n]=a[j]+1;
}
}
if(a[t]) printf("%d\n",a[t]);
else
{
for(i=t-1; i>=0; i--) if(a) break;
printf("%d %d\n",a,t-i);
}
}
}
[/c]