Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
ACM ICPC 2018 World Finals

利用Map照样记忆化算SG(开不下数组就开Map)

Posted by 2422 at 2018-01-12 21:59:30 on Problem 2505
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<set>
#include<cmath>
#include<map>
using namespace std;

map<int,int>M;
int ser(int now){
	if(now==1) return 0;
	if(M[now]) return M[now];
	bool vis[10]={};
	for(int i=2;i<=9;i++)
		vis[ser((int)ceil(1.0*now/i))]=1;
	for(int i=0;i<=9;i++)
		if(!vis[i])
			return M[now]=i;
}

int main(){
	int n;
	char ANS[2][15]={"Stan wins.","Ollie wins."};
	while(~scanf("%d",&n)){
		printf("%s\n",ANS[ser(n)==0]);
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator