1 条题解

  • 3
    @ 2023-7-12 21:06:55
    #include <iostream>
    #include <cmath>
    using namespace std;
    bool prime(int n)
    {
    	int prime = 1;
    	for (int i = 2; i <= sqrt(n); i++)
    	{
    		if (n % i == 0)
    		{
    			prime = 0;
    			break;
    		}
    	}
    	if (prime == 1)
    	{
    		return true;
    	}
    	else
    	{
    		return false;
    	}
    }
    int main()
    {
    	int p[25] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97 };
    	for (int i = 0; i < 25; i++)
    	{
    		for (int j = i + 1; j < 25; j++)
    		{
    			int temp = (p[i] + p[j]) / 2;
    			if (prime(temp) == true && (p[j] - temp == temp - p[i]))
    			{
    				cout << p[i] << " " << temp << " " << p[j] << endl;
    			}
    		}
    	}
    	return 0;
    }
    
    • 1

    信息

    ID
    144
    时间
    1000ms
    内存
    16MiB
    难度
    1
    标签
    递交数
    58
    已通过
    47
    上传者