Skip to content

Instantly share code, notes, and snippets.

@v1k22
Created April 30, 2021 10:15
Show Gist options
  • Select an option

  • Save v1k22/873b4aa0f61e90f3dede5f2dd2782ff8 to your computer and use it in GitHub Desktop.

Select an option

Save v1k22/873b4aa0f61e90f3dede5f2dd2782ff8 to your computer and use it in GitHub Desktop.
Golang template for competitive programming
package main
import (
"bufio"
. "fmt"
"os"
"math"
)
var (
in = bufio.NewReader(os.Stdin)
out = bufio.NewWriter(os.Stdout)
)
func main() {
defer out.Flush()
var L, s1, s2 float64
var q int
Fscan(in, &L, &s1, &s2)
for Fscan(in, &q); q > 0; q-- {
var Q float64
Fscan(in, &Q)
if s1 > s2 {
s1, s2 = s2, s1
}
var Time float64
Time = (math.Sqrt(2) * (L - math.Sqrt(Q))) / (s2 - s1)
if Time >= 0 {
Printf("%.6f\n", Time)
} else {
Time = 0.0000000
Printf("%.6f\n", Time)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment