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

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo » Tue Feb 20, 2007 8:54 am

Try this input..

Code: Select all

100
200
300
400
500
600
700
800
900
1000

My output

Code: Select all

Stan wins.
Ollie wins.
Ollie wins.
Stan wins.
Stan wins.
Stan wins.
Stan wins.
Stan wins.
Stan wins.
Stan wins.
By the way, you can also change the title to what sohel suggested .. :)

Vexorian
Learning poster
Posts: 100
Joined: Sat Aug 26, 2006 5:50 am

Post by Vexorian » Thu Jul 19, 2007 8:38 pm

Maarten wrote:
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
My AC program makes Stan the winner for 13123.

Perhaps judge's I/O is not strong?
Life is NP-complete

vinicius_jssouza
New poster
Posts: 1
Joined: Sat Dec 06, 2008 4:32 am

Re: 847 - A Multiplication Game

Post by vinicius_jssouza » Sat Dec 06, 2008 4:43 am

Please, anybody tell me what's wrong with my approach?

Code: Select all

#include<iostream>

#define stan  true
#define ollie false

using namespace std;

int main()
{
	long long n;
	while (!feof(stdin) && cin >> n)
	{
		bool jogada = stan;
		long long p = 1;

		if (n <= 9) 
		{
			cout << "Stan wins.\n";
			continue;
		}		
		for (; true; jogada = !jogada)
		{
			long long mult = 9;
			while (p * mult * 9 >= n && mult > 1)
				mult--;
			if (mult < 2) break;
			p *= mult;
		}
		if (jogada == stan)
			cout << "Ollie wins.\n";
 		else
			cout << "Stan wins.\n";
	}
	return 0;
}

pieguy
New poster
Posts: 2
Joined: Tue Jun 23, 2009 8:39 pm

Re: 847 - A Multiplication Game

Post by pieguy » Tue Jul 14, 2009 9:37 pm

This problem definitely has weak judge input. I accidentally read "2 OR 9" instead of "2 TO 9" and still got AC. My program should give the wrong output in roughly 25% of cases! (For example, my program claims that Ollie wins from 37 to 72, and that Stan wins from 325 to 648, etc.)

marco2509
New poster
Posts: 3
Joined: Wed Oct 28, 2009 10:59 pm

Re: 847 - A Multiplication Game

Post by marco2509 » Thu Oct 29, 2009 12:20 am

Why I received runtime error.Remember to always terminate your code with the exit code 0.

Code: Select all

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream.h>

unsigned int n;

char w[33][23][15][13];

char getwin( int two,int three,int five,int seven ){
if ( w[two][three][five][seven] != -1 )
return w[two][three][five][seven];


long double x=1.0;

x*=pow( 2.0, two );
x*=pow( 3.0, three );
x*=pow( 5.0, five );
x*=pow( 7.0, seven );

if ( x+0.00000001 >= (long double)n ) return 0;


int k=0;
k+=!getwin(two+1,three,five,seven);
k+=!getwin(two,three+1,five,seven);
k+=!getwin(two+2,three,five,seven);
k+=!getwin(two,three,five+1,seven);
k+=!getwin(two+1,three+1,five,seven);
k+=!getwin(two,three,five,seven+1);
k+=!getwin(two+3,three,five,seven);
k+=!getwin(two,three+2,five,seven);

return w[two][three][five][seven]= k>0;
}

int main() {
FILE *in=fopen( "mult.txt", "r" );
int i,j,k;

while ( 1==fscanf( in, "%u", &n ) ){
memset( w, -1, sizeof(w) );
if ( getwin(0,0,0,0) )
printf( "Stan wins\n" );
else
printf( "Ollie wins\n" );
}
cin.get();
return 0;
}


ericfode
New poster
Posts: 1
Joined: Tue Nov 10, 2009 3:23 am

Re: 847 - A Multiplication Game

Post by ericfode » Tue Nov 10, 2009 3:25 am

This is for problem 847
i am getting a incorrect answer from the judge
any ideas?
thanks in advance
-eric

Code: Select all


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
unsigned long long n;

using namespace std;
int main( void ){

while (cin>>n)
{
	cout <<endl;
	if (n>55009980288) cout << "Ollie Wins." <<endl; else
	if (n>612220032)cout<< "Stan Wins."<<endl ;else
	if (n>306110016)cout<< "Ollie Wins."<<endl ;else
	if (n>34012224)cout<< "Stan Wins."<<endl ;else
	if (n>17006112)cout<< "Ollie Wins."<<endl ;else
	if (n>1889568)cout<< "Stan Wins."<<endl ;else
	if (n>944784)cout<< "Ollie Wins."<<endl ;else
	if (n>104976)cout<< "Stan Wins."<<endl ;else
	if (n>52488)cout<< "Ollie Wins."<<endl ;else
	if (n>5832)cout<< "Stan Wins."<<endl ;else
	if (n>2916)cout<< "Ollie Wins."<<endl ;else
	if (n>324)cout<< "Stan Wins."<<endl ;else
	if (n>162)cout<< "Ollie Wins."<<endl ;else
	if (n>18)cout<< "Stan Wins."<<endl ;else
	if (n>9)cout<< "Ollie Wins."<<endl ;else
	if (n>=1)cout<< "Stan Wins."<<endl ;
	}
}

seraph
New poster
Posts: 9
Joined: Tue Dec 15, 2009 4:18 pm

Re: 847 - A Multiplication Game

Post by seraph » Tue Jan 19, 2010 7:49 am

@ eric :
i know where is your mistake.

1. you should delete this line :

Code: Select all

if (n>55009980288) cout << "Ollie Wins." <<endl; else
2. The word 'Wins' in 'Stan Wins' and 'Ollie Wins' its should change to 'Stan wins' and 'Ollie wins'..
:lol: :lol: :lol: :lol: :lol:

AhmadKhatar
New poster
Posts: 28
Joined: Fri Mar 30, 2012 12:57 am

Re: 847 - A Multiplication Game

Post by AhmadKhatar » Fri Jul 27, 2012 7:56 am

Hi!
Could anybody tell me the reason why the following works:
If n <= 9, Stan wins
Else If n <= 9*2 Ollie wins
Else If n <= 9*2*9 Stan wins
Else If n <= 9*2*9*2, Ollie wins
...etc...
Thanks in advance! :D

hello
New poster
Posts: 25
Joined: Sun Mar 10, 2013 7:29 pm

Re: 847 - A Multiplication Game

Post by hello » Fri Jul 12, 2013 11:57 pm

I really don't understand the problem. What is the real gameplan of stan to select the number at first.The statement says
assume that both of them play perfectly
I think this might be the key. But I also don't understand the meaning of it.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 847 - A Multiplication Game

Post by brianfry713 » Mon Jul 15, 2013 11:25 pm

hello, there is a strategy for the winner to follow that no matter what numbers his opponent chooses he will always win.
Check input and AC output for thousands of problems on uDebug!

hello
New poster
Posts: 25
Joined: Sun Mar 10, 2013 7:29 pm

Re: 847 - A Multiplication Game

Post by hello » Wed Jul 17, 2013 11:53 pm

Then why Ollie always call 2 in the second ? @brianfry713

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 847 - A Multiplication Game

Post by brianfry713 » Thu Jul 18, 2013 11:30 pm

Ollie doesn't always multiply by 2 in the second round. For example if n = 15 then no matter what number Stan multiplies by if Ollie multiplies by 8 he will win.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 8 (800-899)”