description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
input = sys.stdin.readline
def solve():
h, c, t = map( int, input().split())
if h <= t:
return 1
if 2*t <= h+c:
return 2
if 2*h+c <= t*3:
if abs(2*h+c-t*3) >= (h-t)*3:
return 1
else:
return 3
l = 0
r = 500000
whi... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | cases = int(input())
for i in range(cases):
l1 = input().split(' ')
h = int(l1[0])
c = int(l1[1])
t = int(l1[2])
num = 0
#even number of hot and cold
pos1 = (c+h)/2
if t <= pos1:
ans = 2
print(ans)
else:
import math
check = math.floor((h-t)/(2*t-h-c))... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
input = sys.stdin.readline
from collections import *
def judge(x):
return h*(2*x+1)-x*(h-c)>=(2*x+1)*t
def binary_search():
l, r = 0, 10**18
while l<=r:
m = (l+r)//2
if judge(m):
l = m+1
else:
r = m-1
return r
T = int(input... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.util.Scanner;
public class Prob3 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int T = scan.nextInt();
for (int i = 0; i < T; i++) {
int h = scan.nextInt();
int c = scan.nextInt();
int t = scan.nextInt();
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | """ Python 3 compatibility tools. """
from __future__ import division, print_function
import itertools
import sys
import os
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
input = raw_input
range = xrange
filter = itertools.ifilter
map = itertools.imap
zip = itertools.izip
def is_it_local():
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from fractions import Fraction as frac
import sys, os
input = sys.stdin.buffer.read().split(b'\n')[::-1].pop
from heapq import heappush, heappop
def i(): return input()
def ii(): return int(input())
def iis(): return map(int, input().split())
def liis(): return list(map(int, input().split()))
def pint(x): os.wri... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.util.*;
public class Main
{
public static void main(String ars[])
{
Scanner sc=new Scanner(System.in);
int test=sc.nextInt();
for(int xix=0;xix<test;xix++)
{
double h=sc.nextInt()+0.0;
double c=sc.nextInt()+0.0;
double t=sc.nextInt(... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
double h, c, t;
double f(double i) { return (c * (i - 1) + h * (i)) / (2 * i - 1); }
void solve() {
cin >> h >> c >> t;
if (t >= h) {
cout << 1 << endl;
return;
}
if (t <= (h + c) / 2) {
cout << 2 << endl;
return;
}
ll low =... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from decimal import Decimal
def solve():
h,c,t=[int(x) for x in input().split()]
if h==t:
print(1)
return
a=2*t-h-c
b=h-t
if a<=0:
print(2)
return
else:
c1=b//a
c2=c1+1
tc1=Decimal((h*(c1+1)+c*c1))/Decimal((2*c1+1))
tc2=Decimal((h*(... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | T = int(input())
for t_itr in range(T):
H, C, T = list(map(int, input().rstrip().split()))
if T >= H:
print(1)
elif 2 * T <= H + C:
print(2)
else:
n = (C - T) // (H + C - 2 * T)
n1 = n + 1
d1 = H * n + C * (n - 1) - T * (2 * n - 1)
d2 = H * n1 + C * (n... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from decimal import Decimal
import sys
input=sys.stdin.readline
print=sys.stdout.writelines
t=int(input())
for i in range(t):
h,c,t=map(int,input().split())
avg=(h+c)/2
if t<=avg:
k=2
if t>avg:
k=int((h-avg)//(t-avg))
if k%2==0: k+=1
ans=k
mn=10**7
for ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... |
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import static java.lang.Math.min;
public class C implements Closeable {
private InputReader in = new Inpu... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int h, c, t;
cin >> h >> c >> t;
if (t >= h) {
cout << 1 << endl;
} else if (2 * t <= (h + c)) {
cout << 2 << endl;
} else {
double difference = t - (double)(h + c) / 2;
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
#------------------------------warmup----------------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in f... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from decimal import *
getcontext().prec=20
def v1(k):
num = Decimal((k*h)+((k-1)*c))
den = Decimal((2*k)-1)
return num/den
def v(k):
return ((k*h)+((k-1)*c))/((2*k)-1)
import sys
# sys.stdin=open("input.txt",'r')
# sys.stdout=open("output.txt","w")
inf = float('inf')
def low(t):
l,r = 2,10000000
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
;
long long int i, j, t, n, k, l, d, r, p, m, x, y;
cin >> t;
while (t--) {
cin >> n >> m >> k;
if (k <= (n + m) / 2) {
cout << 2 << "\n";
} el... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
# from functools import lru_cache, cmp_to_key
# from heapq import merge, heapify, heappop, heappush
from math import sqrt, ceil, factorial, inf
from collections import defaultdict as dd, deque, Counter as C
# from itertools import combinations as comb, permutations as perm
# from bisect import bisect_left as... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long h, c, t, cnt, ans;
cin >> h >> c >> t;
if (h + c >= t * 2) {
cout << 2 << '\n';
continue;
}
cnt = (t - c) / (t * 2 - h - c);
int x = cnt, y = cnt + 1;
double m = (x * h + (x ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from math import *
def r1(t):
return t(input().strip())
def r2(t):
return [t(i) for i in input().strip().split()]
def r3(t):
return [t(i) for i in input().strip()]
for _ in range(int(input())):
h, c, t = r2(int)
ans1 = abs((h + c)/2 - t)
if ans1 == 0 or 2*t <= (h + c):
print(2)
e... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
# import time,random,resource
# sys.setrecursionlimit(10**6)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
long long x, y, t;
void solve() {
cin >> x >> y >> t;
if (t >= x) {
cout << "1\n";
return;
}
if (t <= (x + y) / 2) {
cout << "2\n";
return;
}
long long ans = (y - t) / (x + y - 2 * t);
long long sol = ans;
for (int i = max(1LL, ans - 10); i <... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | for i in range (int(input())):
a,b,c=map(int,input().split())
d=a-c;
e=c-b;
f=e-d;
if d>=e:
print(2)
elif d==0:
print(1)
elif 2<=(e/d):
if(c*3-(2*a+b))>=(a-c)*3:
print(1)
else:
print(3)
else:
g=round((d+e)/(2*(e-d)))
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #!/usr/bin/env python
# coding:utf-8
# Copyright (C) dirlt
from sys import stdin
def run(h, c, t):
if (h + c - 2 * t) >= 0:
return 2
a = h - t
b = 2 * t - h - c
k = int(a / b)
val1 = abs((k + 1) * h + k * c - (2 * k + 1) * t)
val2 = abs((k + 2) * h + (k + 1) * c - (2 * k + 3) * t)
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
void fast() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
long long int gcd(long long int x, long long int y) {
if (y == 0) return x;
return gcd(y, x % y);
}
long long int lcm(long long int a, long long int b) {
return (a * b) / gcd(a, b);... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | """
This template is made by Satwik_Tiwari.
python programmers can use this template :)) .
"""
#===============================================================================================
#importing some useful libraries.
from fractions import Fraction
import sys
import bisect
import heapq
from math import... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | q = int(input())
for _ in range(q):
h, c, t = map(int, input().split())
if 2 * t <= h + c:
print(2)
continue
l = 1
r = 10 ** 20
while r - l > 1:
m = (r + l) // 2
if (m * h + (m - 1) * c >= t * (2 * m - 1)):
l = m
else:
r = m
a = l
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from sys import stdin
from collections import Counter, deque
from bisect import bisect_left
input = stdin.buffer.readline
T = int(input())
for _ in range(T):
h, c, t = map(int, input().split())
if t*2 <= h+c: print(2); continue
a = int((t-h)/(h-2*t+c))
b = a+1
tt = t*(2*a+1)*(2*b+1)
aa = abs(tt... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
def solve(h, c, t):
if (h+c)>=2*t:
return 2
a = (c-t)/float(h+c-2*t)
a1 = math.floor(a)
a2 = math.ceil(a)
tmp = (2*a2-1)*(a1*h+(a1-1)*c)+(2*a1-1)*(a2*h+(a2-1)*c)-2*t*(2*a1-1)*(2*a2-1)
if tmp<=0:
return 2*a1-1
else:
return 2*a2-1
t = int(input())
for _ in ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
from math import inf
input = sys.stdin.buffer.readline
def prog():
for _ in range(int(input())):
h,c,t = map(int,input().split())
lowest = (h+c)/2
if t <= lowest:
print(2)
elif abs(t-(2*h+c)/3) >= abs(t-h):
print(1)
else:
closest... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
h, c, t = map(int, input().split())
if h <= t:
print(1)
elif (h + c) // 2 >= t:
print(2)
else:
n_c = (h - t) // (2 * t - h - c)
n_h = n_c + 1
if abs((n_c * c + n_h * h) - t * (n_c + n_h)) ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
def minOdd (n,m,h,c,t):
d = abs((n+1)*(2*m+1)*h + (2*m+1)*n*c - t*(2*n+1)*(2*m+1))-abs((m+1)*(2*n+1)*h + (2*n+1)*m*c - t*(2*n+1)*(2*m+1))
if d>0:
return m
elif d<0:
return n
else:
return min(n,m)
def ans (odd,h,c,t):
d = abs(2*(odd+1)*h + 2*odd*c ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | def solver(h, c, t):
if h + c >= 2 * t:
return 2
elif h == t:
return 1
else:
x = (t - c) // (2 * t - h - c)
k1, k2 = abs((2*x-1)*t- ((h+c)*x-c))*(2*x+1), abs(t*(2*x+1) - ((h+c)*x+h))*(2*x-1)
z = 2 * x + 1 if k2 < k1 else 2 * x - 1
return z
for _ in ra... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | def solve(h, c, t):
if t >= h:
return 1
if 2 * t <= h + c:
return 2
if (h - t) % (2 * t - h - c) == 0:
return 2 * (h - t) // (2 * t - h - c) + 1
nn1 = int((h - t) / (2 * t - h - c))
nn2 = nn1 + 1
if (t * (2 * nn2 + 1) - nn2 * (h + c) - h) * (2 * nn1... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | /**
* @author derrick20
*/
import java.io.*;
import java.util.*;
public class MixingWaterDirect {
public static void main(String[] args) throws Exception {
FastScanner sc = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int T = sc.nextInt();
while (T-->0) {
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
double val(long long x, long long h, long long c) {
return ((h * x) + (c * (x - 1))) / ((x * 2.0) - 1.0);
}
int main() {
long long T, h, c, t;
cin >> T;
while (T--) {
cin >> h >> c >> t;
if (t <= (h + c) / 2) {
cout << 2 << "\n";
continue;
}
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
from math import ceil, floor
from functools import cmp_to_key
input = sys.stdin.readline
def main():
tc = int(input())
cmp = lambda a, b: a[0] * b[1] - a[1] * b[0]
cmp = cmp_to_key(cmp)
for _ in range(tc):
h, c, t = map(int, input().split())
if h + c == 2 * t:
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... |
def check(h, c, t, n):
return (n + 1) * h + n * c >= (2 * n + 1) * t
def binsearch(h, c, t):
left = 0
right = 1000000000
while right - left > 1:
mid = (right + left) // 2
if check(h, c, t, mid):
left = mid
else:
right = mid
if check(h, c, t, right):
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | t=int(input())
for test in range(t):
inp=input().split()
h=int(inp[0])
c=int(inp[1])
t=int(inp[2])
if t+t <= c+h:
print(2)
continue
if t >= h:
print(1)
continue
k = (h-t)//(t+t-c-h)
if (h-t)%(t+t-c-h) == 0:
print(k+k+1)
continue
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.util.*;
public class Main {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
public static void main(String[] args) {
new Main().run();
}
void run() {
for (int i = 0; i < n; i++) {
long h = sc.nextLong();
long c = sc.nextLong();
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | for _ in range(int(input())):
h,c,t=map(int,input().split())
h-=c
t-=c
if h==t:
print(1)
elif h/2>=t:
print(2)
else:
#def f(mid):return h*(1+mid)/(1+2*mid)
def p(a):
return h*(1+a)
def q(a):
return 1+2*a
a=0
b=10**10... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
// br = new BufferedReader(new FileRea... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from math import ceil
for _ in range(int(input())):
h,c,t=map(int,input().split())
if((h+c)>=t*2):
print(2)
elif(h-t==0):
print(1)
else:
ans=abs(2*t-c-h)
temp=(ceil((h-t)/ans))
res=1000000
hh=0
cc=0
res2=1
for i in range(max(temp,1)... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | def i_by_t(h, c, t):
return ((h - c) / (t - (h + c) / 2) + 2) / 2
for _ in range(int(input())):
h, c, t = map(int, input().split())
mean = (h + c) / 2
def temp(i):
half = i // 2
return (h * (i - i // 2) + c * half) / i
T = temp(1)
if t >= T:
print(1)
continue... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long T, h, c, t;
cin >> T;
while (T--) {
cin >> h >> c >> t;
long double min_dif = fabs((h + c) / 2.0 - t);
if (h - t >= t - c) {
cout << "2\n";
contin... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
bool sortinrev(const pair<long long, long long> &a,
const pair<long long, long long> &b) {
return (a.first > b.first);
}
long long power(long long x, unsigned long long y) {
long long p = 998244353;
long long res = 1;
x = x % p;
if (x == 0) return 0... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 100001;
long long h, c, temp;
long double f(long long m) {
long double r = 1.0 * (m * h + (m)*c) / (2 * m);
return (abs(r - temp));
}
long double f12(long long m) {
long double r = 1.0 * (m * h + (m - 1) * c) / (2 * m - 1);
return (abs(r - temp));
}... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
from decimal import *
input = sys.stdin.readline
def main():
t = int(input())
for _ in range(t):
H, C, T = [int(x) for x in input().split()]
if H == T:
print(1)
continue
if (H + C) / 2 == T:
print(2)
continue
if (H ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int T;
long long h, c, t;
int main() {
cin >> T;
while (T--) {
cin >> h >> c >> t;
if (h + c >= t * 2) {
cout << 2 << '\n';
continue;
}
long long res = 0;
long long n = ceil((h - t) / (2.0 * t - (h + c)));
long long res2 = ((n * (h + ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import io,os
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
import sys
from math import floor,ceil
def solve(h,c,t):
if h==t:return 1
if 2*t<=h+c:return 2
if 6*t>=5*h+c:return 1
if 3*t>=2*h+c:return 3
if (h-t)%(2*t-(h+c))==0:
cnt=(h-t)//(2*t-(h+c))
return 2*cnt+1
k,l=f... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int h, c, t;
cin >> h >> c >> t;
if (h + c >= 2 * t) {
cout << "2\n";
} else {
int k = (h - t) / (2 * t - h - c);
if (abs((k + 1) * h + k * c - t... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... |
from collections import Counter,defaultdict,deque
#from heapq import *
#import itertools
#from operator import itemgetter
#from itertools import count, islice
#from functools import reduce
#alph = 'abcdefghijklmnopqrstuvwxyz'
#dirs = [[1,0],[0,1],[-1,0],[0,-1]]
#from math import factorial as fact
#a,b = [int(x) for x ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | _ = int(input())
for T in range(_):
h, c, t = [int(x) for x in input().split()]
if t <= (h + c) / 2:
print(2)
continue
x = (t - c) // (2 * t - h - c)
v1 = x * h + (x - 1) * c
v2 = (x + 1) * h + x * c
if abs(v1 - (2 * x - 1) * t) / (2 * x - 1) <= abs(t * (2 * x + 1) - ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.util.*;
public class solution{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int t1=sc.nextInt();
while(t1-->0){
int h=sc.nextInt();
int c=sc.nextInt();
int t=sc.nextInt();
// case 1 n... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
long long h, c, t;
double f(long long num) {
long long tot = (2 * num - 1);
long long val = ceil(tot / 2.) * h + (tot / 2) * c;
double avg = ((double)val / tot);
double ret = fabs(avg - (double)t);
return ret;
}
void test_cases() {
scanf("%lld%lld%lld", &h, &c, ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
long long int T;
cin >> T;
while (T--) {
long long int h, c, t;
cin >> h >> c >> t;
if (t == h) {
cout << "1"
<< "\n";
continue;
}
if (h + c == 2... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e8;
int main() {
int q;
cin >> q;
while (q--) {
long long h, c, t, l, r, m;
cin >> h >> c >> t;
if (t >= h) {
cout << "1\n";
continue;
}
l = 1;
r = 1e9;
while (r - l > 1) {
m = (l + r) / 2;
if ((m * ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
input = sys.stdin.buffer.readline
def I(): return(list(map(int,input().split())))
def sieve(n):
a=[1]*n
for i in range(2,n):
if a[i]:
for j in range(i*i,n,i):
a[j]=0
return a
for __ in range(int(input())):
h,c,t=I()
# for n in range(1,22,2):
# if n%2:
# avg=(h+c*(n-1)//2... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int in(char &c) { return scanf("%c", &c); }
int in(char s[]) { return scanf("%s", s); }
int in(int &x) { return scanf("%d", &x); }
int in(long long &x) { return scanf("%lld", &x); }
int in(double &x) { return scanf("%lf", &x); }
int in(pair<int, int> &p) { return scanf("%d%... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
input = lambda: sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
h, c, t = map(int, input().split())
a = h - t
b = t - c
if a <= 0:
print(1)
elif a >= b:
print(2)
else:
mi = (a, 1)
mii = 1
if abs((a+b) * mi[1]) < mi[0] * 2:
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long MOD = 998244353;
const long long inf = 1e18;
const long long MAX = 2e5 + 1;
inline long long add(long long a, long long b) {
return ((a % mod) + (b % mod)) % mod;
}
inline long long sub(long long a, long long b) {
return... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.io.*;
import java.util.*;
import java.lang.Math;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int T = scan.nextInt();
StringBuilder answer = new StringBuilder();
for (int i = 0; i < T; ++i) {
int h = ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
from decimal import *
tt = int(input())
for t in range(tt):
x2,x1,x0 = input().split(' ')
a1 = int(x1)
a2 = int(x2)
a0 = int(x0)
# if(a0 >= a2):
# print(1)
# continue
if(a0 <= (a1+a2)/2):
print(2)
continue
ans1 = math.floor((a0-a2)/(a1+a2-2*a0))
ans2 = math.ceil((a0-a2)/(a1+a... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
from sys import stdin,stdout
import sys
import fractions
mod=1000000007
F=fractions.Fraction
t=int(stdin.readline())
while t>0:
h,c,tt=list(map(int,stdin.readline().split()))
mini=sys.maxsize
ans=0
if(2*tt>h+c):
low=1
high=1000000
mid=low+(high-low)//2
x=0
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | for _ in range(int(input())):
a,b,c=map(int,input().split())
mid=(a+b)/2
if c==a:
print(1)
elif c<=mid:
print(2)
elif c>=(mid+(a-b)/6) and c<a:
d=(mid+(a-b)/6)
if abs(d-c)<abs(a-c):
print(3)
else:
print(1)
else:
c-=mid
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | t=int(raw_input())
for _ in xrange(t):
h,c,t=map(int,raw_input().split())
if 2*t<=h+c:
print 2
elif t>=h:
print 1
else:
k1=(h-t)/(2*t-h-c)
f1=[(k1+1)*h+k1*c,2*k1+1]
f2=[(k1+2)*h+(k1+1)*c,2*k1+3]
s=[f1[0]*f2[1]+f1[1]*f2[0],f1[1]*f2[1]]
if s[0]<=2*t*s[1]:
print 2*k1+1
else:
print 2*k1+3
|
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
f... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
const long long INF = 9e18;
const long long MOD = 1e9 + 7;
const long long mod = 998244353;
void fileio() {}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
fileio();
long long tc;
cin >> tc;
while (tc--) {
long long h, c, t;
ci... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
try (BufferedInputStream in = new BufferedInputStream(System.in);
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
input=sys.stdin.buffer.readline
nTests=int(input())
for _ in range(nTests):
h,c,t=[int(zz) for zz in input().split()]
#Observe that for every nHot==nCold (nCups//2==0), finalt=(h+c)/2.
#if t<=(h+c)/2, ans=2
#else, find temp(nHot) just larger than t and find temp(nHot+1) or temp(nHot) is clos... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | ans = []
for _ in range(int(input())):
h, c, t = map(int, input().split())
if h + c - 2 * t >= 0:
ans.append(2)
continue
a1 = int((t - c) / (2 * t - h - c))
b1 = a1 - 1
a2 = int((t - c) / (2 * t - h - c)) + 1
b2 = a2 - 1
dt1 = abs(t * (a1 + b1) - (a1 * h + b1 * c)) * (a2 + b2... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | # cook your dish here
from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right
def L():
return list(map(int, stdin.readline().split()))
def In():
return map(int, stdin.readli... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from sys import stdin
from decimal import *
inp = lambda: stdin.readline().strip()
t = int(inp())
for _ in range(t):
h, c, needed = [int(x) for x in inp().split()]
s = 10 ** 6 + 1
l = 0
x = 0
prevWell = -1
if needed == h:
print(1)
elif needed <= (h + c) // 2:
print(2)
e... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
import sys
input = sys.stdin.readline
for _ in range(int(input())):
h, c, t = map(int, input().split())
e = 1000001
x = 1
if t > (c+h)/2:
a = t - (c+h)/2
x = math.ceil(((h-c)/(2*a) + 1)/2)
q = x - 1
if(abs(t - (c+h)/2 - (h-c)/(4*q-2)) <= abs(t - (c+h)/2 - (h... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | T, = map(int, input().split())
def f(h, c, n):
return (h*(n+1)+c*n)/(2*n+1)
def B(h, c, n):
return 2*n+1
def C(h, c, n):
return (h*(n+1)+c*n)
def H(h, c, t, n):
return 2*t*B(h,c,n)*B(h,c,n+1)-C(h,c,n+1)*B(h,c,n)-C(h,c,n)*B(h,c,n+1) >=0
for _ in range(T):
h, c, t, = map(int, input().split())
m... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
from decimal import *
for _ in range(int(input())):
h,c,t = map(int,input().split())
if t <= (h+c)/2:
print(2)
else:
n = math.ceil((h-c)/((2*t)-(h+c)))
# print("before:",n)
if n&1:
print(n)
else:
half = n//2
getcontext().prec = 1000
a1 = Decimal((half*h)+((h... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
import math
from decimal import *
t = int(sys.stdin.readline().strip())
for i in range(t):
h, c, t = list(map(int,sys.stdin.readline().strip().split(' ')))
mid = Decimal(c + (h - c)/2)
if h == t:
print(1)
elif t <= mid:
print(2)
else:
b = int((h - mid)/(t-mid))
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | for _ in range(int(input())):
h,c,t=map(int,input().split())
if(h==t):
print(1)
else:
xx=(h+c)/2
if(xx==t):
print(2)
elif(xx>t):
print(2)
else:
dif=(t-xx)
jj=int(abs((c-h)//(2*dif)))
if(jj%2==0):
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from fractions import Fraction
import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools im... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
from fractions import Fraction
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in r... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in rang... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | for i in range(int(input())):
h,c,t=map(int,input().split())
if (h+c)/2>=t:
print(2)
else:
a = (h-t)//(2*t-h- c)
b = a+1
print(2*a + 1 if 2*t*(2*a+1)*(2*b+1) >= (2*b+1)*((a+1)*h+a*c)+(2*a+1)*((b+1)*h+b*c) else 2 * b + 1) |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int main() {
int cs;
cin >> cs;
while (cs--) {
double h, c, t;
cin >> h >> c >> t;
if (t >= h)
cout << 1 << endl;
else if (t <= (c + h) / 2)
cout << 2 << endl;
else {
long long l = 1, r = 1e9, val;
while (l < r) {
lo... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
long long read() {
long long x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from math import floor
from sys import stdin
input = stdin.readline
def compare_answer(hot, cold, target, moves, ans):
min_temperature = (ans // 2) * (hot + cold) + (ans % 2) * hot
min_error = abs(min_temperature - ans * target) * moves
temperature = (moves // 2) * (hot + cold) + (moves % 2) * hot
err... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from sys import stdin
input=lambda : stdin.readline().strip()
char = [chr(i) for i in range(97,123)]
CHAR = [chr(i) for i in range(65,91)]
mp = lambda:list(map(int,input().split()))
INT = lambda:int(input())
rn = lambda:range(INT())
mod = 10000000007
from math import ceil,sqrt,factorial,gcd
for _ in rn():
h,c,t = m... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | # cook your dish here
import math
def bs(H, C, res):
lo = 0
hi = 10**12
ans = 0
while(lo<=hi):
mid = (lo + hi)//2
if (H*mid + ((mid-1)*C)) >= res*((2*mid) - 1):
lo = mid + 1
ans = mid
else:
hi = mid - 1
return ans
def main():
for q i... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | t = int(input())
for test in range(t):
h, c, t = map(int,input().split(" "))
t-=c
h-=c
if t<=h/2:
print(2)
else:
res=int(h/(2*t-h)/2)
if(abs(t-(res+1)*h/(2*res+1))>abs(t-(res+2)*h/(2*res+3))):
print(2*res+3)
else:
print(2*res+1)
"""
So, what h... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | input=__import__('sys').stdin.readline
from decimal import Decimal
import decimal
decimal.getcontext().prec = 20
def cal1(no,h,c):
ans = Decimal((h+c)*no + h)/Decimal(2*no+1)
return ans
for _ in range(int(input())):
h,c,t = map(int,input().split())
a1=(h+c)/2
l=1
r=1000000
hh=0
if t<=(h+... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | def getClosest(h, c, st, en, t):
if abs(val(h, c, st, t)/(2*st-1)) <= abs(val(h, c, en, t)/(2*en-1)):
return st
else:
return en
def val(h, c, x, t):
return x * h + (x - 1) * c - (2 * x - 1) * t
def findClosest(h, c, st, en, t):
# Corner cases
if val(h, c, st, t) <= 0:
ret... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
template <typename T, typename U>
inline void amin(T &x, U y) {
if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
if (x < y) x = y;
}
template <typename T>
inline void write(T x) {
int i = 20;
char buf[... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
double h, c, t;
double get(int x) {
return fabs(t - (1.0 * x * h + 1.0 * (x - 1) * c) / (1.0 * (x + x - 1)));
}
int main() {
int T;
cin >> T;
while (T--) {
cin >> h >> c >> t;
if (h <= t)
puts("1");
else {
double avg = (h + c) / 2.0;
if... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | T=int(input())
for t in range(T):
h,c,t=map(int,input().split())
h*=2;c*=2;t*=2
m=(h+c)//2
if t<=m:
print(2)
else:
hc,tc=h-m,t-m
tms=hc//tc
apr=[2434841,1]
for i in range(tms-5,tms+5):
if i%2 and abs(tc-hc/i)<apr[0]:
apr=[abs(tc-hc/i),i]
print(apr[1]) |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int h, c, t;
double ans(double);
int binarysearch();
double ghadr(double);
bool check();
int main() {
int T;
cin >> T;
while (T--) {
cin >> h >> c >> t;
if (t <= double(c + h) / 2) {
cout << 2 << endl;
continue;
}
if (h == t) {
cout <... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class cf1359c_2 {
public static void main(String[] args) throws IOException {
int q = ri();
while(q --> 0) {
long h = rnl(), c = nl(), t = nl();
if(t <= (h + c) /... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | def solve(h, c, t):
if t == h:
return 1
if 2 * t <= h + c:
return 2
cands = []
cands.append((h + c, 2, 2))
bx = h - t
by = 2 * t - h - c
b = bx // by
for d in range(2):
bb = b + d
aa = bb + 1
cands.append(( aa * h + bb * c, aa + bb, aa + b... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
from math import ceil, floor
from functools import cmp_to_key
input = sys.stdin.readline
def main():
tc = int(input())
for _ in range(tc):
h, c, t = map(int, input().split())
if h + c == 2 * t:
print(2)
else:
x = max(0, (t - h) // (h + c - 2 * t))
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from math import ceil
for _ in range(int(input())):
h,c,t=map(int,input().split())
if t<=(h+c)/2:print(2)
else:
k=(h-t)//(2*t-h-c)
if abs((2*k+3)*t-k*h-2*h-k*c-c)*(2*k+1)<abs((2*k+1)*t-k*h-h-k*c)*(2*k+3):print(2*k+3)
else:print(2*k+1)
|
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
tt = int(input())
for test in range(tt):
h,c,t = map(int,input().split())
if t<=(h+c)/2: print(2)
else:
k = (h-t)//(2*t-h-c)
# if k hot +1 hot and k cold cups
if abs((k*(h+c)+h)-t*(2*k+1))*(2*k+3)<=abs(((k+1)*(h+c)+h)-t*(2*k+3))*(2*k+1):
print(2*k+1)
e... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
test = int(input())
for _ in range(test):
h,c,t = map(int, input().split())
if t==h:
print(1)
elif t <= (h+c)//2:
print(2)
else:
x = (t-h)/((h+c)-2*t)
ceil = math.ceil(x)
floor = math.floor(x)
if abs(((h+c)*ceil+h)-t*(2*ceil+1))*(2*floor+1) < abs(((h+c)*floor+... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.