Created
April 30, 2021 10:15
-
-
Save v1k22/873b4aa0f61e90f3dede5f2dd2782ff8 to your computer and use it in GitHub Desktop.
Golang template for competitive programming
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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