847 - A Multiplication Game

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

Moderator: Board moderators

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

Using multiplication

Post by rbuchan » Thu Oct 23, 2003 4:44 pm

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

Post by Maarten » Fri Nov 07, 2003 1:21 am

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? :P

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

Question on 847 (multiplication game)

Post by Grazyna » Wed Jun 01, 2005 11:53 am

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

Post by Grazyna » Thu Jun 02, 2005 12:56 am

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
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Sun Jul 17, 2005 9:38 pm

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? :lol: I hope so.
Ami ekhono shopno dekhi...
HomePage

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

Post by Grazyna » Thu Jul 21, 2005 1:21 pm

Thanks Jan for your reply and your nice explanation.
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... :oops:

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

What means "play perfectly"

Post by willima » Wed Feb 08, 2006 9:27 pm

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

Post by renkinjutsushi » Tue Apr 25, 2006 2:53 pm

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

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

WHY WA

Post by Debashis Maitra » Mon Dec 11, 2006 6:40 pm

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
Location: Dhaka, Bangladesh
Contact:

Re: WHY WA

Post by joy » Sun Dec 17, 2006 7:53 am

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

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

Post by Debashis Maitra » Sun Dec 17, 2006 8:39 pm

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
Location: [CSE,BUET],DHAKA,BANGLADESH.

A multiplication game. WWWWWWWAAAAAAAAA plz help

Post by S.M. Arifuzzaman » Tue Feb 13, 2007 11:46 pm

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

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

hmm

Post by sohel » Wed Feb 14, 2007 9:00 am

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
Location: [CSE,BUET],DHAKA,BANGLADESH.

Post by S.M. Arifuzzaman » Wed Feb 14, 2007 6:02 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
Location: [CSE,BUET],DHAKA,BANGLADESH.

Post by S.M. Arifuzzaman » Tue Feb 20, 2007 8:25 am

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.
S. M. Arifuzzaman......
He dreamXtreme..................
But good4nothing................................

Post Reply

Return to “Volume 8 (800-899)”