Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
利用Map照样记忆化算SG(开不下数组就开Map)#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator