847  A Multiplication Game
Moderator: Board moderators
Using multiplication
A converse to this would be to start p = 1, then alternately multiplying it by 9, 2, 9, etc. Once p >= n, the problem is solved.
Cheers
Cheers
Question on 847 (multiplication game)
I read all the posts and I can not find where is the fault in my logic:
I read that is considered corect that from 18 > 162 Stan wins.
Let them choose 50: Stan of course starts with 2. (Otherwise he looses since Ollie will return 81.) Ollie responds with 4. Stan now will return 8 or 36. In any case he will loose. So from 37 > 72 Ollie wins.
Where is the mistake since accepted programs return the opposite?
I read that is considered corect that from 18 > 162 Stan wins.
Let them choose 50: Stan of course starts with 2. (Otherwise he looses since Ollie will return 81.) Ollie responds with 4. Stan now will return 8 or 36. In any case he will loose. So from 37 > 72 Ollie wins.
Where is the mistake since accepted programs return the opposite?
judge wrong ...?
I just got accepted assuming according to the advices of the forum that from 19 > 162 Stan is winning. But still I think that judge is wrong on this problem...
I think u misunderstood the problem description..
You should know that Stan always starts with p=1. He does his multiplication with a number 2  9, then Ollie multiplies.
Clear about the description? I hope so.
You should know that Stan always starts with p=1. He does his multiplication with a number 2  9, then Ollie multiplies.
Code: Select all
For 50 Stan starts with 5,
so p is 5
then Ollie can choose 2 or 9 (min or max respectively)
for 2 p will be 10 and for 9 p will be 45, and thus Stan wins.
For 37 Stan starts with 4,
so p is 4,
then Ollie can choose 2 or 9 (min or max respectively)
for 2 p will be 8 and for 9 p will be 36, and thus Stan wins again.
for 72 Stan starts with 7,
so p is 7,
then Ollie can choose 2 or 9 (min or max respectively)
for 2 p will be 14 and for 9 p will be 63, and thus Stan wins again.
for 18 Stan starts with 2 or 9 (min or max respectively),
so p will be 2 or 9,
then Ollie wins.
for 19 Stan starts with 2.
so p is 2,
then Ollie can choose 2 or 9 (min or max respectively)
for 2 p will be 4 and for 9 p will be 18, and thus Stan wins again.
Ami ekhono shopno dekhi...
HomePage
HomePage
What means "play perfectly"
I didn't understand this term. What does the problem mean when say that both players play perfectly in the game?
Thanks!
Thanks!
"Don't let the day go by
Don't let it end
Don't let the day go by, in doubts
The anwser lis within"
Don't let it end
Don't let the day go by, in doubts
The anwser lis within"

 New poster
 Posts: 2
 Joined: Tue Apr 25, 2006 2:44 pm
 Location: Bogot
847 Problem with the logic
The first time I read the problem I thought:
Let's call "p" the number in which we are right now and "n" the number I want to reach.
The first move I always must try is the biggest number available (i.e. 9)
If I can't win using the biggest number then:
I try the next biggest number "m" in which p * 9 * m < n
So I don't win, but I'm also sure that my opponent doesn't win either and I'm putting pressure so maybe I would won in my next turn.
Of course if
p * 9 * 2 > n
I have already lost.
I tried this logic but I got a WA.
Is there some hole in my logic?
Let's call "p" the number in which we are right now and "n" the number I want to reach.
The first move I always must try is the biggest number available (i.e. 9)
If I can't win using the biggest number then:
I try the next biggest number "m" in which p * 9 * m < n
So I don't win, but I'm also sure that my opponent doesn't win either and I'm putting pressure so maybe I would won in my next turn.
Of course if
p * 9 * 2 > n
I have already lost.
I tried this logic but I got a WA.
Is there some hole in my logic?
You're not your job. You're not how much money you have in the bank. You're not the car you drive. You're not the contents of your wallet. You're not your fucking khakis. You're the allsinging, alldancing crap of the world.

 Learning poster
 Posts: 62
 Joined: Sun Jul 09, 2006 8:31 am
 Location: University of Dhaka
 Contact:
WHY WA
why WA
Code: Select all
Removed
Last edited by Debashis Maitra on Sun Dec 17, 2006 8:55 pm, edited 1 time in total.
Akash chhoyar swopno
Dream to touch the sky
Dream to touch the sky
Re: WHY WA
1 < n < 4294967295Debashis Maitra wrote:why WA
so use unsigned int
form kisui na ... class tai asol....
iF U hv d class u get the form....
iF U hv d class u get the form....

 Learning poster
 Posts: 62
 Joined: Sun Jul 09, 2006 8:31 am
 Location: University of Dhaka
 Contact:

 New poster
 Posts: 10
 Joined: Sun Feb 11, 2007 1:01 pm
 Location: [CSE,BUET],DHAKA,BANGLADESH.
A multiplication game. WWWWWWWAAAAAAAAA plz help
//my code(editted after Mr. Sohel's suggestion)
wa, plz help.
wa, plz help.
Code: Select all
/*********************************multiplicatation game****************/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void main()
{
//freopen("in847.txt","r",stdin);
//freopen("out847.txt","w",stdout);
long j,k=1,found=0;
long long num,p,q;
while(scanf("%lld",&num)==1)
{
k=1,p=1,q=1,found=0;
for(;!found;k++)
{
if(p*9>=num)
{
found=1;
break;
}
else
{
for(j=9;j>=2;j)
{
q=p*j;
if(q*9>=num)
{
continue;
}
else
break;
}
p=q;
}
}
if(k%2)
{
printf("Stan wins.\n");
}
else
{
printf("Ollie wins.\n");
}
}
}
Last edited by S.M. Arifuzzaman on Tue Feb 20, 2007 8:30 am, edited 1 time in total.
S. M. Arifuzzaman......
He dreamXtreme..................
But good4nothing................................
He dreamXtreme..................
But good4nothing................................
hmm
Looks like you are new in this forum.
1] Use the search option to find the existing threads on that problem and use that.
2] Posting the code without any explanation isn't usually a good idea.
3] Use the tags when posting codes.
4] For the title  mention the problem number and name. So your title should have been '847  A multiplication game'
1] Use the search option to find the existing threads on that problem and use that.
2] Posting the code without any explanation isn't usually a good idea.
3] Use the
Code: Select all
4] For the title  mention the problem number and name. So your title should have been '847  A multiplication game'

 New poster
 Posts: 10
 Joined: Sun Feb 11, 2007 1:01 pm
 Location: [CSE,BUET],DHAKA,BANGLADESH.

 New poster
 Posts: 10
 Joined: Sun Feb 11, 2007 1:01 pm
 Location: [CSE,BUET],DHAKA,BANGLADESH.
Can anyone show me the bug in the code posted above??? I'd be really grateful. Plz...
I assume both stan and ollie will try with 9 to get p*9>=n. if fail, the will try with maximum p*j such that their counterpart will not be able to reach n by multiplying at most 9.
I assume both stan and ollie will try with 9 to get p*9>=n. if fail, the will try with maximum p*j such that their counterpart will not be able to reach n by multiplying at most 9.
S. M. Arifuzzaman......
He dreamXtreme..................
But good4nothing................................
He dreamXtreme..................
But good4nothing................................