求救啊

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

awa再也不水贴 @ 2019-11-09 21:20:46

import math
import sys

def sushu(n):
    for i in range (2,sqrt(n)):
        if(n % i == 0):
            return 1
    return 0

n=int(input())
for n1 in range(2,n-4):
    for n2 in range(2,n-4):
        n3 = n-n1-n2
        if(sushu(n1)+sushu(n2)+sushu(n3) != 0):
            continue
        print(n1,n2,n3)
        sys.exit()

RE


by awa再也不水贴 @ 2019-11-09 21:30:43

import math
import sys

def sushu(n):

    n = int(n)
    for i in range(2, int(math.sqrt(n))):
        if (n % i == 0):
            return 1
    return 0

n = int(input())
for n1 in range(2, (n - 4)):
    for n2 in range(2, (n - 4)):
        n3 = ((n - n1) - n2)
        if ((sushu(n1) + sushu(n2)) + sushu(n3) != 0):
            continue
        print(n1, n2, n3)
        sys.exit()

70

3wa


by 0nullptr @ 2019-11-09 22:38:13

@xiaojie233a

循环改成for i in range(2, int(math.sqrt(n)) + 1):


by awa再也不水贴 @ 2019-11-10 09:59:15

@一个python屑 谢谢昂!


by awa再也不水贴 @ 2019-11-10 10:00:15

@一个python屑 啊啊啊!!过了谢谢大佬!


|