Test on 2018.10.21

说是数组超了。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<algorithm>
 5 #include<string>
 6 #include<string.h>
 7 using namespace std;
 8 long long a[1010], b[1010], c[10100000] = { 0 };
 9 bool zhi(int x)
10 {
11     if (x <= 1)    return 0;
12     if (x == 2)    return 1;
13     for (int i = 2; i*i <= x; i++)
14         if (x%i == 0)    return 0;
15     return 1;
16 }
17 int main()
18 {
19     int n, l;
20     cin >> n >> l;
21     for (int i = 1; i <= n; i++)
22         cin >> a[i];
23     for (int i = 1; i <= n - l + 1; i++)
24     {
25         b[i] = 0;
26         for (int j = 1; j <= l; j++)
27             b[i] = b[i] * 10 + a[i + j - 1];
28     }
29     for (int i = 1; i <= n - l + 1; i++)
30         if (zhi(b[i]))
31             c[b[i]] = 1;
32     int kk = 0, sum = 0;
33     int yy = 1;
34     for (int i = 1; i < l; i++)
35         yy = yy * 10;
36     for (int i = yy; i <= yy * 10 - 1; i++)
37         if (c[i])    kk++;
38     for (int i = yy; i <= yy * 10 - 1; i++)
39         if (c[i]) {
40             sum++;
41             cout << i;
42             if (sum == kk)    cout << endl;
43             else    cout << ",";
44         }
45     return 0;
46 }
View Code

 

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<algorithm>
 5 using namespace std;
 6 bool zhi(int x)
 7 {
 8     if(x<=1)    return 0;
 9     if(x==2)    return 1;
10     for(int i=2;i*i<=x;i++)
11         if(x%i==0)    return 0;
12     return 1;
13 }
14 void fenjie(int x)
15 {
16     for(int i=2;i<=x;i++)
17         if(x%i==0)
18         {
19             if(x==i)    cout<<i<<endl;
20             else {cout<<i<<"*";
21             fenjie(x/i);}
22             return ;
23         }
24 }
25 int main()
26 {
27     int n;
28     while(cin>>n){
29     cout<<n<<"=";
30     fenjie(n);}
31     return 0;
32 }

 

不会写占坑

占坑 

占坑

占坑

占坑

No matter how you feel, get up , dress up , show up ,and never give up.
原文地址:https://www.cnblogs.com/Kaike/p/9830858.html