結果

問題 No.955 ax^2+bx+c=0
ユーザー neko_the_shadow
提出日時 2019-12-18 09:33:56
言語 Go
(1.23.4)
結果
WA  
実行時間 -
コード長 803 bytes
コンパイル時間 13,671 ms
コンパイル使用メモリ 223,612 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-07 00:36:14
合計ジャッジ時間 12,307 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 80
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	a := readFloat64()
	b := readFloat64()
	c := readFloat64()

	d := b*b - 4*a*c
	if d > 0 {
		fmt.Println("2")
		say((-b - math.Sqrt(d)) / (2 * a))
		say((-b + math.Sqrt(d)) / (2 * a))
	} else if d == 0 {
		fmt.Println("1")
		say(-b / (2 * a))
	} else {
		fmt.Println("0")
	}
}

func say(x float64) {
	fmt.Printf("%.20f\n", x)
}

var stdin *bufio.Scanner

func read() string {
	if stdin == nil {
		stdin = bufio.NewScanner(os.Stdin)
		stdin.Split(bufio.ScanWords)
		stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	}
	stdin.Scan()
	return stdin.Text()
}

func readInt() int {
	n, _ := strconv.Atoi(read())
	return n
}

func readFloat64() float64 {
	n, _ := strconv.ParseFloat(read(), 64)
	return n
}
0