Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
1359_C. Mixing Water | 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... | 2 | 9 | from math import floor
# inp = open( 'file.txt' ).readline
inp = input
getans = lambda a , b , x , y : ((( a*x ) + (b*y)) , ( x+y ))
for _ in range( int( inp() ) ):
h , c , t = map( int , inp().strip().split(" ") )
if h == t:
print(1)
elif (h+c)/2 >= t:
print(2)
else:
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import math as ma
t=int(input())
for _ in range(t):
h,c,t=list(map(int,input().split()))
if (h+c)//2==t:
print(2)
else:
a=[[abs(h-t),1]]
a.append([abs((h+c)/2-t),2])
if (h+c)/2<t:
b=t-(h+c)/2
e=(h-c)/(2*b)
d=int(e)
f=ma.ceil(e)
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
double h, c, t;
while (n--) {
long long ans = 0;
cin >> h >> c >> t;
if (t <= ((h + c) / 2.0))
cout << "2\n";
else {
long long k = ((h - t) / ((2.0 * t) - h - c));
double ck1 =
abs(((dou... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | # Contest No.: Edu 88
# Problem No.: C
# Solver: JEMINI
# Date: 20200528
import sys
import heapq
def gcd(a, b):
if a < b:
a, b = b, a
if b == 0:
return a
return gcd(b, a % b)
def main():
a = int(input())
for _ in range(a):
h, c, t = map(int, sys.stdin.readline(... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.StringTokenizer;
public class MixingWater {
static long INF=1000000000L;
public static void main(String[] args) throws IOException {
int testNum = Reader.nextInt();... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.wr... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import math
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) | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int T;
int h, c, t;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d%d%d", &h, &c, &t);
if (t * 2 <= (h + c))
printf("%d\n", 2);
else {
long long lef = (h - t) / (2 * t - (h + c));
double a1 = (1.0 * h * (lef + 1) + c * lef) / (2 * lef... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | def f(h,c,t):
if t<= (c+h)/2:
return 2
if t>=h:
return 1
x = (t-c)//(2*t-h-c)
if (4*x*x+2*x-1)*h+(4*x*x-2*x-1)*c <= 2*(4*x*x-1)*t:
return 2*x-1
else:
return 2*x+1
t = int(input())
for i in range(t):
[h,c,t] = input().split(' ')
print(f(int(h),int(c),int(t)))
| PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | def t_on_move(move):
return (move * h + (move - 1) * c) / (2 * move - 1)
for _ in range(int(input())):
h, c, t = list(map(int, input().split()))
even_val = (h + c) // 2
l = 0
r = 2000000000
while r - l > 1:
m = (l + r) // 2
m_val = t_on_move(m)
if m_val > t:
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | from math import floor
t = int(input())
def near(i, h, c):
return abs(((i+1.0)*h + i*c)/(2*i+1.0))
for _ in range(t):
h, c, t = (int(x) for x in input().split())
h = h - t
c = c - t
if h == 0 or h == c:
print(1)
elif h + c >= 0:
print(2)
else:
cand = -(h*1.0)/(h+... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl = lambda: list(map(int, input().split()))
inm = lambda: map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
def ddprint(x):
if DBG:
print(x... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int N = 100010, M = 1010;
int T;
int h, c, t;
int main() {
cin >> T;
while (T--) {
cin >> h >> c >> t;
if ((double)t <= (double)(h + c) / 2.0)
puts("2");
else {
long long k = (long long)(h - t) / (2LL * t - h - c);
long long v1 = abs(... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long T, h, c, t;
signed main() {
cin >> T;
while (T--) {
cin >> h >> c >> t;
if (t + t <= h + c) {
cout << 2 << endl;
continue;
}
if (h <= t) {
cout << 1 << endl;
continue;
}
double ans = (h - t) / (t + t - h - c);
... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
T=N()
def f():
h,c,t=NM()
h-=c
t-=c
if h==t:
print(1)
return
elif t*2<=h:
print(2)
return
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import math
from decimal import *
t = int(input());
for test in range(t):
h,c,t = map(int,input().split());
eavg = (h+c)/2;
if(t<=eavg):
print(2);
continue;
avg = (h-t)/(2*t-h-c);
a1 = max(0,math.ceil(avg));
a2 = max(0,math.floor(avg));
t1 = Decimal((a1+1)*h + a1*c)/(2*a1 + 1... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import math
t=int(input())
for w in range(t):
h,c,te=(int(i) for i in input().split())
d2=(h+c)/2
if(h<te):
print(1)
elif(d2>=te):
print(2)
else:
d=pow(10,18)
x=(te-c)/((2*te)-h-c)
k1=max(1,int(x-10))
k2=int(x+10)
for i in range(k1,k2):
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 |
for ti 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) | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | from math import floor
def f(r,x,y,z):
temp=((r+1)*x + r*y)/(2*r+1)
return abs(temp-z)
for _ in range(int(input())):
h,c,t=map(int,input().split())
av=(h+c)/2
if av>=t:
print(2)
continue
k=floor(((h-t)/(2*t-(h+c))) + 0.5)
temp=abs((((k+1)*h + k*c)/(2*k + 1))-t)
temp1=abs((((k+2)*h + (k+1)*c)/(2*k + 3))-t)
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #AUTHOR pajenegod
import sys, fractions
range = xrange
inp = [int(x) for x in sys.stdin.read().split()]
ii = 0
def rint():
global ii
i = ii
ii += 1
return inp[i]
def rints(n):
global ii
i = ii
ii += n
return inp[i:ii]
def rintss(n, k):
global ii
i = ii
ii += n * k
... | PYTHON |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int _;
cin >> _;
while (_--) {
long long h, c, t;
cin >> h >> c >> t;
if (h + c == 2 * t) {
cout << 2 << endl;
continue;
} else {
long long x = 1LL * (c - t) / (h + c - 2 * t);
double t1 = 1.0 * (x * h + (x - 1) * c... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int N = 2e5 + 10;
int T;
long long h, c, t;
double cal(long long x) {
return abs(1.0 * (h * x + c * (x - 1)) / (2 * x - 1) - 1.0 * t);
}
int main() {
scanf("%d", &T);
while (T--) {
scanf("... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | from fractions import Fraction
from math import ceil, floor
for _ in range(int(input())):
h, c, t = map(int, input().split())
if t * 2 <= h + c:
print(2)
else:
# (t - (h + c) / 2) ~~ ((h - c) / 2) / ans
c1 = t - Fraction(h + c, 2)
c2 = Fraction(h - c, 2)
goal = c2 / ... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | # -*- coding: utf-8 -*-
from math import ceil
from fractions import Fraction
t=int(input())
for iza in range(t):
X=input()
X1=X.split()
h=int(X1[0])
c=int(X1[1])
t=int(X1[2])
h=h-c
t=t-c
c=0
if t<=h/2:
print(2)
else:
if t==h:
print(1)
else:
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import decimal
decimal.getcontext().prec = 20
def get_r(r , n1,n2,i):
d = abs(r - decimal.Decimal((h * (i // 2 + 1) + c * (i // 2))) / decimal.Decimal(i))
return d
t = int(input())
for _ in range(t):
h, c , r = map(int, input().rstrip().split(" "))
if h == r:
print(1)
elif r <= (h+c)/2:
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import decimal
def f(h,c,t):
if (h+c)/2==t:
return 2
n=((h-c)/2)/(t-h/2-c/2)
if n<0:
return 2
if n%2==1 and n==int(n):
return int(n)
n=int(n)
#print(n)
if n%2==0:
n1=n-1
n2=n+1
if n==0:
n1=n+1
else:
n1=n
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import sys
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)
ans = []
for _ in range(tc):
h, c, t = map(int, input().split())
if h + c == 2 * t:
ans.append(2)
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import sys
from fractions import gcd
from math import ceil,sqrt,sin,pi,tan
from collections import defaultdict
read=sys.stdin.buffer.readline
import heapq
mi=lambda:map(int,read().split())
li=lambda:list(mi())
cin=lambda:int(read())
for _ in range(cin()):
h,c,t=mi()
if t==h:
print(1)
continue
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long h, c, t;
double check(int cnt) {
return ((double)cnt * (double)h + ((double)cnt - (double)1) * (double)c) /
(2.0 * cnt - 1.0);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt;
cin >> tt;
while (tt--) {
cin >> h >>... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long h, c;
long double x = 1.0;
long double get(long long moves) {
long double x = 1.0;
return c + ((moves) / (2 * moves - 1.0)) * (h * x - c * x);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, t, m, y, z, temp;
cin >> t;
wh... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
long long gcd(long long a, long long b) {
long long temp;
if (a < b) {
temp = b;
b = a;
a = temp;
}
if (a % b == 0) {
return b;
}
return gcd(b, a % b);
}
long long modu(long long a, long long b) {
if (a... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | import math
def solve():
T = int(input())
while (T > 0):
hct = input().split()
h = int(hct[0])
c = int(hct[1])
t = int(hct[2])
if (t <= (h+c)/2):
print(2)
else:
k1 = math.ceil((t-c)/(2*t-h-c))
k2 = math.floor((t-c)/(2*t - h - ... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import sys
q=int(input())
for i in range(q):
h,c,t=[int(j) for j in sys.stdin.readline().split()]
if t==h:
print(1)
elif t<=(h+c)/2:
print(2)
else:
first=(h+c)/t
first1=(h+c)/2
second=(h-t)//(2*t-h-c)
if second==second+1:
if second==0:
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | 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)) * (n_c + n_h + 2) > abs((n_c * c + n_h * h + h... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | def solve():
h, c, t = map(int, input().split())
if h == t:
result = 1
elif t <= (h + c) / 2:
result = 2
else:
k = (t - c - 1) // (2 * t - h - c)
result = 2 * k + 1
result -= 2 if (4 * k * k - 1) * (2 * t - h - c) >= 2 * (h - c) * k else 0
print(result)
def main():
for _ in range(int(input())):
solv... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int solve() {
double h, c, t;
cin >> h >> c >> t;
if (t <= (c + h) / 2) return 2;
int k = (h - t) / ((2 * t) - h - c);
double tk1 = ((k * (h + c)) + h) / ((2 * k) + 1);
double tk2 = (((k + 1) * (h + c)) + h) / ((2 * k) + 3);
if (abs(t - tk1) <= abs(t - tk2)) r... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | import java.io.*;
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
static long f(long x, long h , long c) {
return x * (h + c) + h;
}
static long solve(long num1, long num2, long h, long c, long temp) {
long x1 = (nu... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | from decimal import *
def value(n,h,c,t):
getcontext().prec = 100
a = Decimal(n*h + (n-1)*c)/Decimal(2*n - 1)
return abs(a-Decimal(t))
t = int(input())
for i in range(t):
h,c,t = list(map(float,input().split()))
if(t == h):
print(1)
elif(t - (h+c)/2 <= 0):
print(2)
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | T = int(input())
for iteration in range(T):
[h, c, t] = list(map(int, input().split()))
if t <= (h+c)/2:
print(2)
else:
k = 1/2 * (h-c)/(2*t-h-c)
k = k + 1/(4*(int(k)+1))
if k - int(k) <= 10**(-8):
k = int(k) - 1
else:
k = int(k)
print... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
private static FastReader fastReader = new FastReader();
public static void main(String[] args) {
Task solver = new Task();
solver.solve();
}
static class Task {
private static StringBuilder result = new StringBuilder();
... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | from math import *
T = int(input())
for T in range(1, T+1):
h, c, t = input().split()
h = int(h)
c = int(c)
t = int(t)
if (t<=((h+c)/2)):
ans = 2
#print(ans)
elif (t>= h):
ans = 1
#print(ans)
else:
k = (t-c)//(2*t-(h+c))
if ((t-c)%(2*t-(h+c))==0):
ans = (2*k)-1
else:
if (((((k*h)+((k-1)*c... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | T=int(input())
C=[]
for i in range (0,T):
h,c,t = [int(x) for x in input().split(' ')]
if h+c==2*t:
C.append(2)
elif 2*t<h+c:
if abs((h+c)/2-t)<abs(h-t):
C.append (2)
else:
C.append(1)
else:
m= (h-t)//(2*t-h-c)
if abs(((m+2)*h+(m+1)*c)*(2*m... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const double Pi = acos(-1.0);
const long long dx[] = {0, 0, 1, -1};
const long long dy[] = {1, -1, 0, 0};
const long long N = (long long)1e6 + 17;
const long long M = (long long)2e3 + 69;
const long long inf = (long long)1e14 + 3;
const long long mod = (long long)1e9 + 7;
l... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | import math
def getValue(num, data):
[hot, cold, t] = data
more = math.ceil(num)
less = math.floor(num)
f = (hot * more + cold * (more - 1)) / (2 * more - 1)
s = (hot * less + cold * (less - 1)) / (2 * less - 1)
if ((more - num) * 10 == 5): return more
if (abs(f - t) < abs(s - t)): ret... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
bool f(int n, int h, int c, int t) {
return (2 * n + 1ll) * abs(1ll * n * (h + c - 2 * t) + t - c) <=
(2 * n - 1ll) * (1ll * n * (h + c - 2 * t) + h - t);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
long long t = 1;
cin >> t;
while (t--)... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scan... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | #!/usr/bin/env python
from __future__ import division, print_function
import os
import sys
import math
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def main():
T = int(input())
for _ ... | PYTHON |
1359_C. Mixing Water | 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... | 2 | 9 | from fractions import Fraction as f
import sys
t = int(input())
for _ in range(t):
h, c, t = [int(x) for x in input().split()]
if h == t:
print(1)
continue
x = (h + c) / 2
if x == t:
print(2)
continue
ans = abs(f(h + c, 2) - t)
ans2 = 2
if abs(h - t) <= ans:
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | t=int(input())
for i in range(t):
h1,c1,t1=input().split(" ")
h=int(h1)
c=int(c1)
t=int(t1)
if (t<=(h+c)/2):
print(2)
else:
x=(t-c) // (2*t-h-c)
m=((h+c)*x-c)/(2*x-1)-t
n=t-((h+c)*x+h)/(2*x+1)
if (m<n):
print(2*x-1)
elif(m==n and m==i... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import java.io.*;
import java.math.*;
import java.util.*;
public class Sol2{
public static void main(String[] args) throws IOException{
FastIO sc = new FastIO(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-->0) {
double h = sc.nextInt();
double c = sc.nextInt();
... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | import sys
input = sys.stdin.readline
INF = 10**13
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for h, c, t in Query:
if 2*t <= h+c:
ans = 2
else:
l = 0
r = INF
while r - l > 1:
m = (l+r)//2
if (h+c)*m+h > (2*m+1)*t:
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import math
def getval(y, h, c, t):
return abs(((((y+1)*h + y*c) - (2*y+1)*t))/(2*y+1))
for _ in range(int(input())):
h, c, t = map(int, input().split())
avg = (h+c)/2
if (avg >= t):
print(2)
continue
b = (t-h)/(h+c-2*t)
b1 = math.ceil(b)
if (getval(b1-1, h, c, t) <= getval(... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import java.util.*;
import java.io.*;
public class C88
{
static int c, h, temp;
public static void main(String [] args)
{
MyScanner sc = new MyScanner();
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
int t = sc.nextInt();
while (t > 0) {
... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | import math
t = int(input())
for _ in range(t):
h,c,t = list(map(int, input().split(' ')))
mid = (h+c)/2
if t <= mid:
print(2)
elif t >= h:
print(1)
else:
x = (h-t)/(2*t-h-c)
x1 = int(math.floor(x))
x2 = int(math.ceil(x))
t1 = (h-c)*(x1+1)*(2*x2+1)+(... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | from sys import maxint
from math import floor
Q = input()
for q in range(Q) :
H, C, T = map(int, raw_input().split())
base = (H+C) / 2.0
if base >= T : print 2
else :
k = int(floor((H-T) / float(2*T-H-C)))
k0 = abs(k*(H+C)+H - T*(2*k+1)) * (2*k+3)
k1 = abs((k+1)*(H+C)+H - T*(2*k+3)) * (2*k+1)
... | PYTHON |
1359_C. Mixing Water | 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... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class code {
public static void main(String[] args)throws IOException {
FastReader sc = new FastReader();
PrintWriter pw = new PrintWriter(System.out);
int t1 = sc.n... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
impo... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | # -*- coding: utf-8 -*-
import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
from typing import List
"""
created by shhuan at 2020/6/10 22:37
"""
def solve(H, C, T):
if T >= H:
return 1
if T <= (H+C)//2:
return 2
k = int((T-H)... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | from sys import stdin
from collections import deque
# https://codeforces.com/contest/1354/status/D
mod = 10**9 + 7
import sys
import random
# sys.setrecursionlimit(10**6)
from queue import PriorityQueue
# def rl():
# return [int(w) for w in stdin.readline().split()]
from bisect import bisect_right
from bisect impor... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | from decimal import *
getcontext().prec = 28
n = int(input())
for i in range(n):
h,c,t = list(map(int, input().split()))
if (2*h+c)/3 < t <= h :
if abs(t - (2*h+c)/3) < abs(t-h):
print(3)
else:
print(1)
elif (h+c)/2 >= t:
print(2)
else:
k = (h-t)//... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import math
def getValue(num, data):
[hot, cold, t] = data
more = math.ceil(num)
less = math.floor(num)
f = (hot * more + cold * (more - 1)) / (2 * more - 1)
s = (hot * less + cold * (less - 1)) / (2 * less - 1)
if (abs(f - t) < abs(s - t) or (more - num) * 10 == 5): return more
else: ... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | /**
* @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) {
... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | 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:
valh=(c-t)//(h+c-2*t)
valc=valh-1
ans=abs((h*valh+c*valc)-t*(2*valh-1))
ans1=(2*valh-1)
valh1=valh+1
va... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
long long int mod = 1e9 + 7;
using namespace std;
const long long int INF = 1e18;
const long long int MAX = 2e5 + 10;
long long int power(long long int a, long long int b) {
if (b == 0) return 1;
long long int num = 1;
long long int m = mod + 2;
while (b != 1) {
if (b % 2 == 0) {
... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | import math
def getValue(num, data):
[hot, cold, t] = data
more = math.ceil(num)
less = math.floor(num)
f = (hot*more + cold*(more-1)) / (2 * more - 1)
s = (hot*less + cold*(less-1)) / (2 * less - 1)
if (abs(f - t) == abs(s - t)):
if ((more - num) * 10 == 5): return more
retu... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
inline long long ceil(long long a, long long b) { return (a + b - 1) / b; }
long double h, c, tb;
long double calc(long double x) {
long double res = (x + 1) * h + x * c;
res /= (2 * x + 1);
res = abs(res - tb);
return res;
}
void func() {
cin >> h >> c >> tb;
i... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | #!/usr/bin/python3.8
from fractions import Fraction
from math import floor, ceil
def f(h, c, x):
return Fraction(h * (x + 1), x * 2 + 1) + Fraction(c * x, x * 2 + 1)
def solve():
h, c, t = [int(x) for x in input().split()]
a = h + c
d1 = Fraction(h + c, 2)
if h + c >= t * 2:
print(2)
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | cases = int(input())
for _ in range(cases):
h, c, t = [int(x) for x in input().split()]
if t <= (h+c)/2:
print(2)
continue
n = (t-h)/(h+c-2*t)
x, y = int(n), int(n)+1
xx = ((x+1)*h+x*c)
yy = ((y+1)*h+y*c)
if xx*(2*y+1)+yy*(2*x+1) <= 2*t*(2*y+1)*(2*x+1):
print(2*x+1)
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | """
// Author : snape_here - Susanta Mukherjee
"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def ii(): return int(... | PYTHON |
1359_C. Mixing Water | 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... | 2 | 9 | import sys
input = sys.stdin.buffer.readline
def print(*val):
sys.stdout.write(str(*val) + '\n')
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_... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | // package 第1359场;
/* 盗图小能手
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
long long int T, t, n, m, h, c, ini, fin;
double can, aux, can2;
int main() {
cin >> T;
while (T--) {
cin >> h >> c >> t;
aux = t;
if (t >= h)
cout << 1 << "\n";
else {
if (t <= ((h + c) / 2))
cou... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long T = 1;
cin >> T;
while (T--) {
long long h, c, t;
cin >> h >> c >> t;
if (t == h) {
cout << 1 << "\n";
continue;
}
if (2 * t <= (h + c)) {
cout << 2 << "\n";
continue;
}
long long x = (t - c) /... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
class Time {
chrono::high_resolution_clock::time_point start;
public:
Time() { start = chrono::high_resolution_clock::now(); }
~Time() {
cout << "\nTime: "
<< chrono::duration_cast<chrono::duration<double>>(
chrono::high_resolution_clock... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | test=int(input())
while test:
h,c,t=map(int,input().split())
choto=abs((h+c)-t)
if (h+c-2*t)*(t-c)>=0:
print(2)
else:
x=int((c-t)/(h+c-2*t))
m=abs((x*(h+c-2*t)+t-c)/(2*x-1))
n=abs(((x+1)*(h+c-2*t)+t-c)/(2*(x+1)-1))
if m<=n:
print(2*x-1)
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | def f(h,c,t,x):
n=x*2+1
return abs((h*(x+1)+c*x)-t*n)
for _ in range(int(input())):
h,c,t=map(int,input().split())
if h+c>=t*2:print(2);continue
if h<=t:print(1);continue
ans1=(h-t)//(2*t-h-c)
ans2=ans1+1
if f(h,c,t,ans1)*(2*ans2+1)<=f(h,c,t,ans2)*(2*ans1+1):print(ans1*2+1)
else:print(ans2*2+1) | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | for _ in range(int(input())):
h,c,t = map(int,input().split())
if t<=(h+c)/2:
print(2)
else:
x = (h-t)//(2*t-h-c)
v1 = ((x+1)*h + x*c)
v2 = ((x+2)*h + (x+1)*c)
# print(v1,v2)
# print(abs(v1-(2*x+1)*t)/(2*x+1),abs(t*(2*x+3)-v2)/(2*x+3))
if abs(v1-(2*x+... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | from math import *
s=int(input())
for _ in range(s):
h,c,t=map(int,input().split())
k=(h+c)/2
if k>=t:
ans=2
else:
d=(h-t)
x=2*t -h-c
l=d//x
a=(l+1)*h +l*c
m=abs(a-t*(2*l +1))
m=m*(2*l +3)
b=(l+2)*h +(l+1)*c
n=abs(b-t*(2*l ... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import java.util.*;
public class CodeForces1359C{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int q = input.nextInt();
for(int i = 0;i<q;i++){
int h = input.nextInt();
int c = input.nextInt();
int t = input.nextInt();
if(2*t <= h+c){
System.out.println(2);
... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 |
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
public class Prac{
static class InputReader {
private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
public InputReader(InputStream st) {
... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
double h, c, t;
double f(ll i) { return (ll((i + 1) / 2) * h + ll(i / 2) * c) / (double)i; }
void solve() {
cin >> h >> c >> t;
if (t >= h) {
cout << 1 << endl;
return;
}
if (t <= (h + c) / 2) {
cout << 2 << endl;
return;
}
... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | from decimal import Decimal
t = int(input())
for _ in range(t):
h, c, t = [int(x) for x in input().split()]
s = h + c
if 2 * t <= h + c:
print(2)
elif t == h:
print(1)
else:
denom = (2 * t) - h - c
alpha1 = (h - t) // denom
alpha2 = alpha1 - 1
alpha3 = alpha1 + 1
val1 = Decimal(alpha1 * s + h) / ... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | import math
for _ in range(int(input())):
h, c, t = map(int, input().split())
if t == h:
print(1)
continue
if 2*t <= (h + c):
print(2)
continue
x = max(1,((t-c) //(2 * t - h - c)))
y=x+1
# print(x,y)
try1=((x*h)+(x-1)*c)
try2=((y*h)+(y-1)*c)
diff1=abs(... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | 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)
ans = []
for _ in range(tc):
h, c, t = map(int, input().split())
if h + c == 2 * t:... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | /*
I FOLLOW THE WAY OF THE RIGHT HONOURABLE JIM KWIK,
GOD BLESS YOU SIR
1. I AM A 'NEWBIE' IN RATING
2. I WILL FAIL MANY TIMES, BUT I WILL NOT FAIL TO LEARN FROM FAILURE
3. I WILL NEVER SURRENDER MY GOAL, NO MATTER HOW MUCH I FAIL
4. I WILL PROVE MY SKILLS WHEN THE TIME COMES
5. I WILL ALWAYS KEEP TRYING
*/
... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
FastScanner sc = new FastScanner(System.in);
int t = sc.nextInt();
for(int ti = 0; ti < t; ti++){
long h = sc.nextInt();
long c = sc.nextInt();
... | JAVA |
1359_C. Mixing Water | 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... | 2 | 9 | from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
h,c,t = map(int,input().split())
if 2*t <= h+c:
print(2)
else:
t*=2
h*=2
c*=2
w = h//2-c//2
pod = (h+c)//2
#w/(2k+1) jak najblizej t-pod
goal = t-pod
if goal == 0:
print(1)
else:
x = w//goal
wynik = 2
min... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | from fractions import Fraction as F
t = int(input())
for _ in range(t):
h,c,t = map(int,input().split())
if 2 * t - h - c == 0:
k = 0
else:
k = (h - t) // (2 * t - h - c)
t = F(t)
def f(mid):
return F(mid * (h + c) + h, 2 * mid + 1)
res, tmp = 10 ** 100, F(10 ** 100)
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | from math import inf
t=int(input())
for _ in range(t):
h,c,t=map(int,input().split())
min1=abs(t-h)
min2=abs(t-(h+c)/2)
min3=inf
if t<(h+c)/2:
print(2)
elif 2*t==(h+c):
print(2)
elif t==h:
print(1)
else:
a1=int((t-c)/(2*t-h-c))
a2=a1+1
if abs((h*a2+c*(a2-1)-t*(2*a2-1))*(2*a1-1)
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | def inp():
return(int(input()))
import math
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(list(s[:len(s) - 1]))
def invr():
return(map(int,input().split()))
import bisect
#python3 codeforces_1359C.py
T = inp()
def odds(num):
high = math.ceil(num)
low = mat... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | for _ in range(int(input())):
h, c, t = map(int, input().split())
if h <= t:
print(1)
continue
if h + c >= t*2:
print(2)
continue
lo = 1
hi = 10**10
while lo < hi:
mid = (lo + hi + 1) // 2
totTemp = mid * h + (mid-1) * c
if totTemp // (mid ... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | for T in range(int(input())):
h ,c , x =list(map(int,input().split()))
if h == x :
print(1)
else :
av = (h+c)/2
if av >=x :
print(2)
else :
n = (h-x)//(2*x -h -c)
p = n +1
temp = ((h+c)*n + h)*(2*p +1)
... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | 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 file.mode or "r" not in file.mode
self.write = self.buffer.write if self... | PYTHON3 |
1359_C. Mixing Water | 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... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long int i, k, j, h, t, c;
cin >> h >> c >> t;
if (t == h) {
cout << 1 << '\n';
return;
}
if (t == (h + c) / 2) {
cout << 2 << '\n';
return;
}
if (t < (h + c) / 2) {
cout << 2 << '\n';
return;
}
double n;
n = (... | CPP |
1359_C. Mixing Water | 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... | 2 | 9 | for _ in range(int(input())):
h,c,t=map(int,input().split())
if (h+c)//2>=t:print(2)
elif h==c:print(1)
else:
i=(t-c)//(2*t-h-c)
p=abs((i*(h+c-2*t)+t-c)/(2*i-1))
q=abs(((i+1)*(h+c-2*t)+t-c)/(2*(i+1)-1))
print(2*i-1) if p<=q else print(2*i+1)
... | PYTHON3 |
1379_E. Inverse Genealogy | Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in... | 2 | 11 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | JAVA |
1379_E. Inverse Genealogy | Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, m, k;
bool works(int n, int k) {
if (!(n & 1) || k < 0) return 0;
if (k < 2) return k ^ !(n & (n + 1));
if (n == 9 && k == 2) return 0;
return 2 * k + 3 <= n;
}
void sol(int n, int k, int p) {
int x = ++m;
cout << p << (x > ::n ? '\n' : ' ');
for (int i... | CPP |
1379_E. Inverse Genealogy | Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int n, k, a[100500], cnt = 1;
bool A[5][5];
bool can(int i, int j) {
if (j < 0 || j > i) return 0;
if (i <= 4) return A[i][j];
if (((i + 1) & -(i + 1)) == (i + 1)) return j != 1 && j != i;
return j != 0 && j != i;
}
void work(int st, int n, int k) {
if (n == 0) re... | CPP |
1379_E. Inverse Genealogy | Ivan is fond of genealogy. Currently he is studying a particular genealogical structure, which consists of some people. In this structure every person has either both parents specified, or none. Additionally, each person has exactly one child, except for one special person, who does not have any children. The people in... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
template <typename T>
T mul(T a, T b) {
return (1LL * a * b) % MOD;
}
template <typename T>
T add(T a, T b) {
return (a + b) % MOD;
}
template <typename T>
T sub(T a, T b) {
return ((a - ... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.