## 847 - A Multiplication Game

Moderator: Board moderators

rbuchan
New poster
Posts: 27
Joined: Fri Feb 28, 2003 7:59 am
Contact:

### 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

Maarten
Experienced poster
Posts: 108
Joined: Sat Sep 27, 2003 5:24 pm
why 13123 makes Stan the winner?
My AC program makes Ollie the winner for 13123. In fact, I'd like to know very much your strategy to make Stan win. Wanna play a game of multiplication with n=13123? I will play Ollie, anyone volunteer to play Stan?

Grazyna
New poster
Posts: 16
Joined: Wed Apr 20, 2005 2:44 pm
Location: Thessaloniki,Greece

### 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?

Grazyna
New poster
Posts: 16
Joined: Wed Apr 20, 2005 2:44 pm
Location: Thessaloniki,Greece

### 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...

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
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.

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.``````
Clear about the description? I hope so.
Ami ekhono shopno dekhi...
HomePage

Grazyna
New poster
Posts: 16
Joined: Wed Apr 20, 2005 2:44 pm
Location: Thessaloniki,Greece
Everything is clear now , and it should be long time ago,
if I was more carefull. I misunderstood the problem, and I was so sure that I didn't bother myself to read the problem...

willima
New poster
Posts: 13
Joined: Wed Dec 07, 2005 1:19 pm
Location: Brazil

### 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!
"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"

renkinjutsushi
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 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 all-singing, all-dancing crap of the world.

Debashis Maitra
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

joy
New poster
Posts: 48
Joined: Wed Oct 18, 2006 1:00 pm
Contact:

### Re: WHY WA

Debashis Maitra wrote:why WA
1 < n < 4294967295
so use unsigned int
form kisui na ... class tai asol....
iF U hv d class u get the form....

Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:
thanx joy u are right
Akash chhoyar swopno
Dream to touch the sky

S.M. Arifuzzaman
New poster
Posts: 10
Joined: Sun Feb 11, 2007 1:01 pm

### A multiplication game. WWWWWWWAAAAAAAAA plz help

//my code(editted after Mr. Sohel's suggestion)
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................................

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

### 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

Code: Select all

`` ``
tags when posting codes.

4] For the title - mention the problem number and name. So your title should have been '847 - A multiplication game'

S.M. Arifuzzaman
New poster
Posts: 10
Joined: Sun Feb 11, 2007 1:01 pm
Thnx Sohel bhai for ur valuable suggestion.
S. M. Arifuzzaman......
He dreamXtreme..................
But good4nothing................................

S.M. Arifuzzaman
New poster
Posts: 10
Joined: Sun Feb 11, 2007 1:01 pm