#13907: C WA (line:1)


t28650636 (33333333)


#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main() {
    int a, b, c, d, e, f;
    while(scanf("%d%d%d", &a, &b, &c)!=EOF){
        d = b * b - 4 * a * c;
    if(d > 0){
        e = (-b+sqrt(b*b-4*a*c))/(2*a);
        f = (-b-sqrt(b*b-4*a*c))/(2*a);
        printf("Two different roots x1=%d , x2=%d\n", e, f);
    }else if (d == 0){
        f = -sqrt(c);
        printf("Two same roots x=%d\n", f);
    }else {
        printf("No real root\n");
    }
 }
 return 0;
}

 

#3: 5% WA (line:1)

您的答案為: Two same roots x=-1
正確答案為: Two same roots x=1

請問哪裡錯誤呢?
#13910: Re:C WA (line:1)


anandrewboy70900 (ShowTsai)


重根不是那樣




#13911: Re:C WA (line:1)


a0970580085@gmail.com (/)


#include
#include
#include

int main() {
    int a, b, c, d, e, f;
    while(scanf("%d%d%d", &a, &b, &c)!=EOF){
        d = b * b - 4 * a * c;
    if(d > 0){
        e = (-b+sqrt(b*b-4*a*c))/(2*a);
        f = (-b-sqrt(b*b-4*a*c))/(2*a);
        printf("Two different roots x1=%d , x2=%d\n", e, f);
    }else if (d == 0){
        f = -sqrt(c);
        printf("Two same roots x=%d\n", f);
    }else {
        printf("No real root\n");
    }
 }
 return 0;
}

 

#3: 5% WA (line:1)

您的答案為: Two same roots x=-1
正確答案為: Two same roots x=1

請問哪裡錯誤呢?


重跟 不是-sqrt(c)
試試 1 -2 1