循环数

  题目链接:循环数,一开始我还以为要用高精度按照题意一个个数去乘来判断,后来百度了下发现原来对于"循环数"早就有人去研究的了,先附上几个链接:

  Cyclic Number

  Artin's Constant

  循环数

  妙趣横生的完全循环数

  按照百科上已算好的几个循环数就能打表直接判断了:

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<string>
 4 #include<map>
 5 #include<algorithm>
 6 using namespace std;
 7 
 8 string s[10] = {
 9     "142857",       // (6位)
10     "0588235294117647",     // (16位)
11     "052631578947368421",       // (18位)
12     "0434782608695652173913",       // (22位)
13     "0344827586206896551724137931",     // (28位)
14     "0212765957446808510638297872340425531914893617",    // (46位)
15     "0169491525423728813559322033898305084745762711864406779661",    // (58位)
16     "016393442622950819672131147540983606557377049180327868852459",      // (60位)
17 };
18 
19 int wei[10] = {7, 17, 19, 23, 29, 47, 59, 61};
20 
21 char p[70];
22 
23 int main() {
24     map<string,int> m;
25     for(int i = 0; i <= 7; ++i)
26         m[s[i]] = s[i].size() + 1;
27     while(~scanf("%s",p))
28         puts(m[p] ? "Yes": "No");
29     return 0;
30 }
View Code
原文地址:https://www.cnblogs.com/Newdawn/p/4652210.html