U E D R , A S I H C RSS

A_Multiplication_Game/권영기

#include<stdio.h>
#define swap(s, w) t = s, s = w, w = t;
long long int t;
long long int n, start1, end1, start2, end2;
long long int getStart(long long int start, int cnt)
{
	long long int temp;
	if(cnt % 2 == 1){
		temp = start/9;
		if(temp * 9  < start)temp++;
		return temp;
	}
	else{
		temp = start/2;
		if(temp * 2 < start)temp++;
		return temp;
	}
}
int main(void)
{

	int cnt;
	while(scanf("%lld", &n) == 1){
		cnt = 0;
		start2 = n;
		while(1)
		{
			cnt++;
			end1 = start2 - 1;
			start1 = getStart(start2, cnt);
			if(start1 <= 1 && 1 <= end1)break;
			swap(end1, end2);
			swap(start1, start2);
		}

		if(cnt % 2 == 1)printf("Stan wins.\n");
		else printf("Ollie wins.\n");
	}
	return 0;
}

ACM_ICPC/2012스터디
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:24
Processing time 0.0173 sec