user-0 提问: 注册第一天，大一小生暑假acm训练中。有哪位大神能抽空做一下吗

回复:
user: user-1
content: 引用 3 楼 甜茶callmeby 的回复:acm.hdu.edu.cn 是这个吗  是的

user: user-0
content: 引用 4 楼 Italink的回复:形如2 2 3 这样的也算吧  #include<iostream> using namespace std; const int MAX = 3001; bool isPrim(int x) { 	if (x <= 1) 		return false; 	int len = sqrt(x); 	for (int i = 2; i <= len; i++) 		if (x % i == 0) 			return false; 	return true; } int main() { 	int n, primList[MAX], len = 0, sum, maxSum = 0, count = 0; 	cin >> n; 	for (int i = 0; i <= n; i++) {	//构建素数表 		if (isPrim(i)) 			primList[len++] = i; 	} 	primList[len] = MAX;		//设置边界哨兵 	for (int i = 0; primList[i] <= n; i++) { 		for (int j = i; primList[j] <= n; j++) { 			for (int k = j; primList[k] <= n; k++) { 				sum = primList[i] + primList[j] + primList[k]; 				if (isPrim(sum)) { 					//cout<< primList[i] <<"+"<< primList[j] <<"+"<< primList[k]<<"="<<sum<<endl; 					count++; 					if (sum > maxSum) 						maxSum = sum; 				} 			} 		} 	} 	cout << count << " " << maxSum << endl; 	return 0; }  谢谢谢谢，一定好好看

user: user-2
content: 形如2 2 3 这样的也算吧  #include<iostream> using namespace std; const int MAX = 3001; bool isPrim(int x) { 	if (x <= 1) 		return false; 	int len = sqrt(x); 	for (int i = 2; i <= len; i++) 		if (x % i == 0) 			return false; 	return true; } int main() { 	int n, primList[MAX], len = 0, sum, maxSum = 0, count = 0; 	cin >> n; 	for (int i = 0; i <= n; i++) {	//构建素数表 		if (isPrim(i)) 			primList[len++] = i; 	} 	primList[len] = MAX;		//设置边界哨兵 	for (int i = 0; primList[i] <= n; i++) { 		for (int j = i; primList[j] <= n; j++) { 			for (int k = j; primList[k] <= n; k++) { 				sum = primList[i] + primList[j] + primList[k]; 				if (isPrim(sum)) { 					//cout<< primList[i] <<"+"<< primList[j] <<"+"<< primList[k]<<"="<<sum<<endl; 					count++; 					if (sum > maxSum) 						maxSum = sum; 				} 			} 		} 	} 	cout << count << " " << maxSum << endl; 	return 0; }

user: user-0
content: acm.hdu.edu.cn 是这个吗

user: user-1
content: 能把ACM的链接给我一个吗？ 我也想玩玩。  代码如下，希望正确。 #include<stdio.h> #include<stdbool.h> #include<stdlib.h> #include<time.h>  #define N 50  long long QuickPow(long long a,long long n,long long MOD){     long long ret=1,tmp=a%MOD;     while(n){         if(n&1) ret=ret*tmp%MOD;         tmp=tmp*tmp%MOD;         n>>=1;     }     return ret; }  bool Miller_Rabin(long long x, long long a) // a^(x-1) = 1 (mod x) {     long long tmx = x - 1;     long long s2 = tmx & -tmx;     long long res = QuickPow(a, tmx/s2, x);     if(res == 1 || res == tmx)         return 1;     while(s2>1)     {         res=(res*res)%x;         if(res == 1)             return 0;         if(res == tmx)             return 1;         s2>>=1;     }     return 0; }  bool IsPrime(long long x, int k) {     if(x == 2 || x == 3) return 1;     if(x < 2 || x%2 == 0 || x%3 == 0) return 0;     while(k--)         if(!Miller_Rabin(x, rand()%(x-2)+2))             return 0;     return 1; }  int main(){     long long m,n;     long long i;     long long sum=0;     long long tmp=0;     long long primeList[3000];          int primeCount = 0;          int count=0;     int k;     srand(time(NULL));     scanf("%lld", &n);     m = 3;     for(i=m;i<=n;i++)     {         if(IsPrime(i, N))         {             primeList[count++] = i;         }     }     for(i = 0; i < count - 2; i ++)     {         for(long j = i + 1; j < count - 1; j ++)          {             for(long z = j + 1; z < count; z ++)             {                 tmp = primeList[i] + primeList[j] + primeList[z];                 if(IsPrime(tmp, N))                 {                     primeCount ++;                     if(sum < tmp)                     {                         sum = tmp;                     }                 }             }         }     }     printf("%d %lld",primeCount,sum);     return 0; }

user: user-3
content: #include <stdio.h> #include <math.h>  #define MAX_NUM 3000  int main() {     int i, j, k, s, f, u, w, max;     int n, p[3 * MAX_NUM], q[MAX_NUM];     int m;      printf("input:");     scanf("%d", &n);      if(n > MAX_NUM)         return 0;      // step 1 : 素数标记p[i]=1     for(i = 3; i <= 3 * n; i = i + 2)     {         f = 1;         u = (int)sqrt(i);         for(j = 3; j <= u; j = j + 2) {             if(i % j == 0) {                 f = 0;                 break;             }         }         if(f == 1)             p[i] = 1;     }      // step 2 : 共w个不大于n的奇素数数q[w]     w = 0;     for(i = 3; i <= n; i = i + 2) {         if(p[i]==1) {             w++;             q[w] = i;         }     }      // step 3 : 三重循环枚举所有三个素数组     m = 0;      // 全素组个数     max = 0;    // 最大全素组     s = 0;      // 3个素数之和     for(i = 1; i <= w - 2; i++)  {         for(j = i + 1; j <= w - 1; j++) {             for(k = j + 1; k <= w; k++) {                 s= q[i] + q[j] + q[k];                 if(p[s] == 1) {                     m++;                     if(s > max)                         max =s;                 }             }         }     }      printf("ouput: %d %d\n", m, max);      return 0; }