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.
Moderator: Board moderators
Code: Select all
100
200
300
400
500
600
700
800
900
1000
Code: Select all
Stan wins.
Ollie wins.
Ollie wins.
Stan wins.
Stan wins.
Stan wins.
Stan wins.
Stan wins.
Stan wins.
Stan wins.
My AC program makes Stan the winner for 13123.Maarten wrote: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?why 13123 makes Stan the winner?
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;
}
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;
}
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 ;
}
}
Code: Select all
if (n>55009980288) cout << "Ollie Wins." <<endl; else
I think this might be the key. But I also don't understand the meaning of it.assume that both of them play perfectly