Created
April 13, 2014 08:23
-
-
Save tzengyuxio/10574475 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python | |
# | |
# author: [email protected] | |
# usage: cat file.input | ./qround-problem-a.py > file.output | |
import sys | |
# 計算建完 n 個農場所需時間 | |
def calc_time(c, f, n): | |
tt = 0.0 | |
for i in range(n): | |
tt += (c / (2 + i * f)) | |
return tt | |
def solve(): | |
s = sys.stdin.readline()[:-1] | |
c, f, x = [float(x) for x in s.split()] | |
n = (int)(((x * f - c - c) / (c * f) ) - 1) + 1 # 最佳解時的農場數量 | |
postfix = " >>" + repr(n) | |
if n <= 1: | |
t = (x / 2) | |
else: | |
t = calc_time(c, f, n) + (x / (2 + n * f)) | |
return repr(round(t, 7)) | |
t = (int)(sys.stdin.readline()) | |
for i in range(t): | |
print 'Case #' + repr(i+1) + ': ' + solve() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment