10465 - Homer Simpson
Moderator: Board moderators
10465 - Homer Simpson
[cpp]
#include <iostream.h>
#include <string.h>
#define min(a,b)(a<b ? a : b)
#define MAX 10005
int tt[MAX];
int main(){
int m,n,t;
while (cin >> m >> n >> t){
memset(tt,0,4*(t+1));
tt[m]=(m!=0);
tt[n]=(n!=0);
int i=min(m,n);
while (i<=t)
{
if (tt){
if (i+m<=t && tt+1>tt[i+m] ) tt[i+m]=tt+1;
if (i+n<=t && tt+1>tt[i+n] ) tt[i+n]=tt+1;
}
++i;
}
if (tt[t]==0){
int i=t-1;
int imin=0;
while (i>-1){
if ( tt>tt[t] ) { tt[t]=tt; imin=i; }
--i;
}
cout<<tt[t]<<" "<<t-imin;
cout<<endl;
}
else cout << tt[t]<<endl;
}
return 0;
}
[/cpp]
Does anyone have some tests ?. I couldn't what's wrong with my code.[/cpp]
#include <iostream.h>
#include <string.h>
#define min(a,b)(a<b ? a : b)
#define MAX 10005
int tt[MAX];
int main(){
int m,n,t;
while (cin >> m >> n >> t){
memset(tt,0,4*(t+1));
tt[m]=(m!=0);
tt[n]=(n!=0);
int i=min(m,n);
while (i<=t)
{
if (tt){
if (i+m<=t && tt+1>tt[i+m] ) tt[i+m]=tt+1;
if (i+n<=t && tt+1>tt[i+n] ) tt[i+n]=tt+1;
}
++i;
}
if (tt[t]==0){
int i=t-1;
int imin=0;
while (i>-1){
if ( tt>tt[t] ) { tt[t]=tt; imin=i; }
--i;
}
cout<<tt[t]<<" "<<t-imin;
cout<<endl;
}
else cout << tt[t]<<endl;
}
return 0;
}
[/cpp]
Does anyone have some tests ?. I couldn't what's wrong with my code.[/cpp]
DID IT WORK?
Hey prom, did you get the program working. just curious to see if the minimal drinking is true. Cause they sure didn't say so.
-
- Experienced poster
- Posts: 193
- Joined: Thu Sep 19, 2002 6:39 am
- Location: Indonesia
- Contact:
Hello, KE4MTG ... prom is right.
Check this clarification about Homer Simpson problem:
http://acm.uva.es/board/viewtopic.php?t=2429
Good luck,
-turuthok-
Check this clarification about Homer Simpson problem:
http://acm.uva.es/board/viewtopic.php?t=2429
Good luck,
-turuthok-
The fear of the LORD is the beginning of knowledge (Proverbs 1:7).
Still Confused :(
My sample inputs
4 4 10
1 7 10
2 3 6
11 2 13
2 5 25
3 4 5
My programme's output...
2 2
10
3
2
11
1 1
Am I correct?? If so still I gor a W.A
otherwise what's wrong with
this samples??
4 4 10
1 7 10
2 3 6
11 2 13
2 5 25
3 4 5
My programme's output...
2 2
10
3
2
11
1 1
Am I correct?? If so still I gor a W.A
![:(](./images/smilies/icon_frown.gif)
this samples??
-
- Guru
- Posts: 647
- Joined: Wed Jun 26, 2002 10:12 pm
- Location: Hong Kong and New York City
- Contact:
I got:
Have you tried m, n >t ?
Code: Select all
2 2
10
3
2
11
1 1
-
- Learning poster
- Posts: 94
- Joined: Sat Oct 05, 2002 5:34 pm
- Location: CS - AIUB, Dhaka, Bangladesh.
- Contact:
To Larry,
i have got WA as well.. the above output is OK in my program, too..
what about the following input???
the Output in my program....
is it correct???
i have got WA as well.. the above output is OK in my program, too..
what about the following input???
Code: Select all
20 30 7
100 8 1
Code: Select all
0 7
0 1
Sajid Online: www.sajidonline.com
-
- Learning poster
- Posts: 94
- Joined: Sat Oct 05, 2002 5:34 pm
- Location: CS - AIUB, Dhaka, Bangladesh.
- Contact:
Turuthuk, then what is the problem.. i cant get...
can u tell me more critical inputs???, plz
![:(](./images/smilies/icon_frown.gif)
can u tell me more critical inputs???, plz
Last edited by Sajid on Fri Mar 07, 2003 3:30 am, edited 1 time in total.
Sajid Online: www.sajidonline.com
Maybe you can try this:
Input:
My solution gives:
Output:
G' Luck ^_^!
Raysa
Input:
Code: Select all
5 3 5
4 5 7
9 7 62
2 5 6
45 23 91
5 9 19
4 6 42
3 7 10
12 56 71
50 51 103
Output:
Code: Select all
1
1 2
8
3
3
3
10
2
2 3
2 1
Raysa
Furious and frustated
Give me a simple input for which my programme..Gives answer different from u...
In fact all the samples from this page satisfy my programme very well..
![:(](./images/smilies/icon_frown.gif)
In fact all the samples from this page satisfy my programme very well..
![:(](./images/smilies/icon_frown.gif)
-->Shafi
" Rajputro has spoken. "
" Rajputro has spoken. "
At last
Understood the problem and Got accepted
:D:D:D:D:D:D
123 12 21 was the faulty input which helped me to correct my problem
![:D](./images/smilies/icon_biggrin.gif)
123 12 21 was the faulty input which helped me to correct my problem
-->Shafi
" Rajputro has spoken. "
" Rajputro has spoken. "