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 |
怒了,帖一个史上最简单的打表解法。#include<iostream> #include<string> #include<map> using namespace std; map<string, int> dic; string sline; void init(){ string str[8] = {"142857","0588235294117647","052631578947368421","0434782608695652173913","0344827586206896551724137931", "0212765957446808510638297872340425531914893617","0169491525423728813559322033898305084745762711864406779661", "016393442622950819672131147540983606557377049180327868852459"}; for(int i=0;i<8;i++) dic[str[i]]=1; } int main(){ init(); while(cin>>sline){ if(dic.count(sline)==1) cout<<sline<<" is cyclic"<<endl; else cout<<sline<<" is not cyclic"<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator