50分。。。有些ac有些wa有些tle。。。求助各位大佬,谢谢

P1579 哥德巴赫猜想(升级版)

吠悟 @ 2020-02-09 11:59:19


#include<iostream>
#include<cmath>
using namespace std;
bool isprime(int x)
{
    int s = sqrt(double(x));
    for (int i = 2;i <= s;i++)
    {
        if (x % i == 0)
            return false;
    }
    return true;
}
int main()
{
    int n,count=0;
    cin >> n;
    int a[10000];
    int min=99999, minx=0,miny=0,minz=0;
    for (int i = 2; i <= n;i++)
    {
        if (isprime(i))
        {
            a[count] = i;
            count++;
        }
    }
    for (int i = 0;i <= count;i++)
    {
        for (int j = i;j <= count;j++)
        {
            for (int k = j;k <= count;k++)
            {
                if (a[i] + a[j] + a[k] == n)
                {
                    if (a[i] < min)
                    {
                        min = a[i];
                        minx = a[i];
                        miny = a[j];
                        minz = a[k];
                    }
                }
            }
        }
    }
    cout << minx << " " << miny << " " << minz;
}

by 吠悟 @ 2020-02-09 12:12:42

@缥缈于尘 全都WA...


by Dimly_dust @ 2020-02-09 12:14:11

缥缈于尘 的运势
§ 大凶 §
诸事不宜
忌:打chunithm
今天状态不好
忌:玩网游

怪不得


by Dimly_dust @ 2020-02-09 12:14:49

@吠悟


by 吠悟 @ 2020-02-09 12:15:25

@缥缈于尘 问题解决了,也谢谢你啦


by zhanghzqwq @ 2020-02-09 12:15:37

zhanghanzhang 的运势
§ 大吉 §
宜:继续完成WA的题
下一次就可以AC了
宜:体育锻炼
身体棒棒哒
万事皆宜

by zhanghzqwq @ 2020-02-09 12:15:51

hhh


by Dimly_dust @ 2020-02-09 12:18:34

@zhanghanzhang 崩溃


上一页 |