#22423: PYTHON求解


kaihunggod@gmail.com (張凱閎)


import sys
y = 1
while y > 0:
    for a in sys.stdin:
        s1 = []
        aa = a.split()
        for aaa in aa:
            s1.append(int(aaa))
        if s1[2] < 0:
            c = s1[2] * -1
        if s1[2] == 0:
            print('Two same roots x=0')
            break
        elif s1[0] == s1[1] and s1[1] == s1[2]:
            print('No real root')
            break
        else:
            for d in range(1, c):
                if s1[2] % d == 0:
                    if -(s1[2] / d) + (-d) == s1[1]:
                        print('Two different roots x1=',d , 'x2=',(s1[2]// d))
                        break
        y = y - 1
 
想問這句'Two different roots x1=',d , 'x2=',(s1[2]// d)要如何讓資料沒有空白鍵 因為印出來x1= -5中間會有空白
 
#22426: Re:PYTHON求解


snakeneedy (蛇~Snake)


想問這句'Two different roots x1=',d , 'x2=',(s1[2]// d)要如何讓資料沒有空白鍵 因為印出來x1= -5中間會有空白

有兩種方法

print('Two different roots x1=%d , x2=%d' % (1, 3)) print('Two different roots x1={} , x2={}'.format(1, 3))
#22427: Re:PYTHON求解


snakeneedy (蛇~Snake)


想問這句'Two different roots x1=',d , 'x2=',(s1[2]// d)要如何讓資料沒有空白鍵 因為印出來x1= -5中間會有空白

有兩種方法

print('Two different roots x1=%d , x2=%d' % (1, 3)) print('Two different roots x1={} , x2={}'.format(1, 3))