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... | from sys import stdin
for _ in range(int(stdin.readline())):
h,c,t = map(int,stdin.readline().split())
if t>=h:
print(1)
continue
if t <= (h+c)/2:
print(2)
continue
n = 1/(1-2*((h-t)/(h-c)))
x = round(n)
if x%2==0:
y = x-1
ex = 2*t*y*(y+2)-2*((y//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... | from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
h, c, t = map(int, input().split())
d = abs((t << 1) - h - c)
ans = 2
l, r = 0, 1000000
while r - l > 1:
mid = (l + r) >> 1
if (h + c) * mid + h < t * (mid << 1 | 1):
r = mid
else:
... |
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 inf = 0x3f3f3f3f;
const long long INF = 2e18;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
int tc;
cin >> tc;
while (tc--) {
long long h, c, t;
cin >> h >> c >> t;
if (t >= h) {
cout << "1\n";
} else {
... |
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(nullptr);
int round;
cin >> round;
for (; round; round--) {
int h, c, t;
cin >> h >> c >> t;
if (h <= t) {
cout << 1 << endl;
continue;
} else if (c >= t) {
cout << 2 << endl;
... |
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 MOD = 1e9 + 7;
long long gcdf(long long a, long long b) {
while (a != 0 && b != 0) {
if (a > b) {
a %= b;
} else {
b %= a;
}
}
return max(a, b);
}
long long power(long long a, long long b, long long m) {
long long ans = 1;
while (... |
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.math.*;
public class Main {
static class Pair implements Comparable<Pair>{
int a;
int b;
public Pair(int x,int y){a=x;b=y;}
public Pair(){}
public int compareTo(Pair p){
return p.a - a;
}
}
static class cell implements Comparable<cell>{
... |
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 sol, k1, k2;
double h, c, t, best, diff, k, t1, t2, pola;
int main() {
cin >> T;
while (T--) {
cin >> h >> c >> t;
pola = (h + c) / 2;
if (t >= h) {
cout << "1" << endl;
continue;
} else if (t <= pola) {
cout << "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... | // package Round_88;
import java.io.*;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.*;
public class Mixing_Water {
public static void main(String[] args) {
FastReader in = new FastReader();
int numTrials = in.nextInt();
while(numTrials --> 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 math import gcd
import sys
def input():
return sys.stdin.readline().rstrip()
dxy = ((-1, 0), (0, -1), (1, 0), (0, 1))
def slv():
#print("hello world")
h, c, t = map(int, input().split())
V = []
if t == h:
print(1)
return
if 2*t <= h + c:
print(2)
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 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... |
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 process_test_case(i_t):
h, c, t = map(int, input().split())
if 2 * t <= h + c:
print(2)
return None
if t == h:
print(1)
return None
t -= 0.5 * (h + c)
n1 = math.ceil(((h - c) / t - 2) / 4)
n2 = n1 - 1
delta1 = abs(t - (h - c) / (4 * n1 +... |
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 temp(h, c, n):
return h * (n + 1) + c * n, 2 * n + 1
for _ in range(int(input())):
h, c, t = map(int, input().split())
if t * 2 <= (h + c):
print(2)
continue
n = (h - t) // (2 * t - h - c)
n1 = n + 1
a, b = temp(h, c, n)
a1, b1 = temp(h, c, n1)
d, dn = abs(a - b * 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... | """
NTC here
"""
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from decimal import Decimal, getcontext
getcontext().prec = 40
def iin(): return int(input())
def lin(): return list(map(Decimal, input().split()))
from types import GeneratorType
def bootstrap(f, stack=[]):
def wrappe... |
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 collections import deque
# import heapq
# from math import inf
# from math import gcd
# print(help(deque))
# 26
pprint = lambda s: print(' '.join(map(str, s)))
input = lambda: sys.stdin.readline().strip()
ipnut = input
for i in range(int(input())):
# n = int(input())
h,c,t= map(... |
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... | //package codeforces.educational_88;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.StringTokenizer;
public class _88_C2 {
public static void main (String[] args) throws Exception {
// String s = "1\n" +
// "9733... |
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.InputStreamReader;
import java.util.Scanner;
public final class C {
public static void main(String[] args) {
final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
final int t = in.nextInt();
for (int x = 0; 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 fractions import Fraction
T = int(input())
def solve(h, c, t):
return Fraction((t - h), (h + c - 2 * t))
def with_a(a, h, c):
return Fraction(((a+1) * h + a * c), (2*a + 1))
def closest(t, poss):
best_delta = float('inf')
best = None
for steps, p in poss:
if abs(t - p) < best_delta... |
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 func(long long k) {
return abs((double)(k * h + (k - 1) * c) / (double)(2 * k - 1) - (double)t);
}
void ternary(int l, int r) {
int yaz;
while (r - l > 0) {
int m1 = l + (r - l) / 3;
int m2 = r - (r - l) / 3;
double f1 = func(m1);
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 math
from decimal import *
from sys import stdin, stdout
T = int(input())
def calc(x, y, n, m):
n = Decimal(n)
m = Decimal(m)
# print(x, y, n, m, (x * n + y * m) / (n + m))
return (x * n + y * m) / (n + m)
def bs(x, y, t):
lo = 1
hi = 1000000000
# print(x, y, t)
while lo<=hi:
mid = int((lo + hi) ... |
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):
if (h + c) / 2 >= t:
return 2
k = (t - h) // (h + c - 2 * t)
# k = Decimal(k)
# k = math.ceil(k)
delta = lambda k: abs(Decimal((k * (h + c)) + h) / (2 * k + 1) - t)
candidates = (k, delta(k)), (k + 1, delta(k + 1))
return sorted(can... |
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.Arrays;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.joining;
public class Main {
void solve() {
long h = in.nextInt();
long c = in.nextInt();
long t = in.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... | for _ in range(int(input())):
h,c,t = map(int,input().split())
if h+c - 2*t>=0:
print(2)
continue
else:
a = h-t
b = 2*t - h - c
k = a//b
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)
... |
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 i in range(T):
h, c, t = map(int, input().split())
avg = (h + c) / 2
if avg >= t:
print(2)
else:
n = ((h - c) / (2 * (t - avg)) + 1) / 2
if type(n) == int:
print(2 * n - 1)
else:
n_min = int(n)
n_max = n_min + 1
diff_n_min = abs(t - avg - (h - c) / (2 * (2 * n_min - 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 tc;
scanf("%d", &tc);
for (int _ = 0; _ < int(tc); _++) {
int h, c, t;
scanf("%d%d%d", &h, &c, &t);
if (h + c - 2 * t >= 0)
puts("2");
else {
int a = h - t;
int b = 2 * t - c - h;
int k = 2 * (a / 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;
long long int power(long long int x, long long int y);
long long int gcd(long long int a, long long int b);
vector<long long int> ft = {1};
long long int modInv(long long int i) { return power(i, 1000000007 - 2); }
long long int ncr(long long int n, long long int r) {
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... | #!/bin/python3
# Not sure why people get so many failed submissions. Numerical error?
from fractions import Fraction
for _ in range(int(input())):
hot, cold, temp=map(int, input().split())
if temp>=hot: print(1); continue
if temp*2<=hot+cold: print(2); continue
x=int(1/((temp-Fraction(hot+cold)/2)/(hot-cold))/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 sys
import math
input = sys.stdin.readline
for f in range(int(input())):
h,c,t=map(int,input().split())
if t==h:
print(1)
else:
if t<=(h+c)/2:
print(2)
else:
diff=t-(h+c)/2
k1=math.floor(((h-c)/(2*diff)-1)/2)
k2=k1+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... | from math import floor, ceil
tests = int(input())
for _ in range(tests):
h,c,t = map(int,input().split())
if 2*t <= h + c:
print(2)
else:
m = (h-t)/(2*t-h-c)
if m == 0:
print(1)
else:
m1 = ceil(m)
m2 = floor(m)
if abs(((m2+1)*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>
#pragma warning(disable : 4996)
const int maxn = 1e5 + 5;
const double Inf = 10000.0;
const double PI = acos(-1.0);
using namespace std;
double h, c, t;
double a;
double f1(int x) { return ((x)*h + (x - 1) * c) / (1.0 * (2 * x - 1)); }
double f2(int x) { return ((x - 1) * h + (x)*c) / (1.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... | import sys
[t] = [int(i) for i in sys.stdin.readline().split()]
for _ in range(t):
[h, c, t] = [int(i) for i in sys.stdin.readline().split()]
h -= c
t -= c
# if t <= h/2:
if 2*t <= h:
print(2)
else:
# k = 1/(2-h/t)
# k = t/(2t-h)
k1 = t // (2*t-h)
k2 = ... |
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
"""
infinite water:
h = hot water
c = cold water (c < h)
"""
from fractions import Fraction
from math import floor, ceil
Decimal = Fraction
def calc_temp(cups, h, c):
# cups = total cups
if cups <= 0:
return 0
if cups % 2 == 0:
return ((h * (cup... |
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... | //package main;
import java.io.*;
import java.util.*;
import java.lang.*;
import java.math.*;
public class Submission {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter (System.... |
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=stdin.readline
from collections import deque
R=lambda:map(int,input().split())
I=lambda:int(input())
S=lambda:input().rstrip('\n')
for _ in range(I()):
h,c,t=R()
if (h+c)/2>=t:print(2);continue
k=int((t-h)/(h+c-2*t))
print(2*k+1 if abs((k*(h+c)+h-t*(2*k+1)))*(2*k+3)<=abs(((k+1)*(h+c)+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;
void solve() {
double x, y, t;
cin >> x >> y >> t;
if (t == x) {
cout << 1 << endl;
return;
}
if ((x + y) >= 2 * t) {
cout << 2 << endl;
return;
}
int n = (t - y) / ((2.0) * t - x - y);
int n_ = n + 1;
double diff1 = abs(t - ((double)n * 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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.InputMismatchException;
import java.util.*;
import java.io.*;
public class Main{
public static class InputReader {
private InputStream stream;
private byte[] buf = new byte[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;
const long long logN = 20;
const long long M = 1000000007;
const long long INF = 1e18;
void solve() {
long long h, c, t;
cin >> h >> c >> t;
if (h == t)
cout << 1;
else if (2 * t <= (h + c))
cout << 2;
else {
long double p = (long long)(h - t) / (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... | for _ in range(int(input())):
h,c,t=map(int,input().split())
if t-h==0:
print(1)
elif 2*t<=(h+c):
print(2)
else:
k=(h-t)//(2*t-(h+c))
if abs((k+1)*h+k*c-t*(2*k+1))*abs(2*k+3)<=abs((k+2)*h+(k+1)*c-t*(2*k+3))*abs(2*k+1):
print(2*k+1)
else:
pr... |
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... | import java.io.*;
import java.util.*;
final public class C {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int tst = Integer.parseInt(br.readLine());
whil... |
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 collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
def eprint(*args):
print(*args, file=sys.stderr)
zz=1
from math import *
import copy
#sys.setrecursionlimit(10**6)
if zz:
input=sys.stdin.readline
else:
sys.stdin=open('input.txt', 'r')
sys.std... |
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 int n, T, x, y, z;
int main() {
ios::sync_with_stdio(false);
cin >> T;
while (T--) {
cin >> x >> y >> z;
if (x <= z)
cout << 1 << endl;
else if ((float)(x + y) / 2 >= z)
cout << 2 << endl;
else {
long long int lb = 1, rb = 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... | from sys import stdin, stdout
import math
t = int(stdin.readline())
for _ in range(t):
h, c, t = map(int, stdin.readline().split())
if 3*(2*t-h) >= 2*h+c:
print(1)
continue
if 2*t <= (h+c):
print(2)
continue
n = (h-t)//(2*t-h-c)
a1, b1 = (h*(n+1)+c*n), 2*n+1
a2, ... |
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 equal(double a, double b) { return abs(a - b) < 1e-13; }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int ntest;
cin >> ntest;
while (ntest--) {
long long c, h, x, y, t, ans = 2;
cin >> h >> c >> t;
long double 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
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
def gift():
for _ in range(t):
h,c,tem = list(map(int,input().split()))
if h==tem:
yield 1
elif (h+c)/2>tem:
mid=(h+c)/2
edif=abs(h-c)
ldif=abs(mid-c)
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long test;
cin >> test;
while (test--) {
long long h, c, t;
cin >> h >> c >> t;
long double mini = (h + c) / 2.0;
if (t <= mini) {
cout << 2 << '\n';
} else {
long 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... | import java.util.*;
import java.io.*;
public class C1359 {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
static StringTokenizer st;
public static void main(String[]args)throws IOExcept... |
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 *
T= int(input())
for i in range(T):
h,c,t= map(int,input().split())
a=h-t
b=2*t-h-c
if b<=0:
print(2)
else:
e=math.ceil(a/b)
r=abs(Decimal(((h+c)*e+h))/Decimal((2*e+1)) - t)
r1=abs(Decimal((h+c))/2 - t)
e1=e+1
e2... |
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--) {
double h, c, t;
cin >> h >> c >> t;
if ((h + c) / 2 >= t)
cout << "2" << endl;
else {
int a = (t - c) / (2 * t - h - c);
double A = ((h + c) * a - c) / (2 * a - 1) - t;
double B = ((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())
import math
for _ in range(T):
h,c,t = map(int,input().split())
ans = 1145141919810
av = (h+c)/2
if av >= t:
print(2)
elif t == h:
print(1)
else:
an = h-av
bn = t-av
x = math.ceil(an / bn)
aa = x//2 * 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;
vector<vector<int>> comp;
vector<int> onecycle;
vector<int> clength;
vector<int> v9;
vector<int> v8;
int cycle_start;
int cycle_end;
vector<int> vbip1;
vector<int> vbip2;
void addedge(int u, int v, vector<int> adj[]) {
adj[u].push_back(v);
adj[v].push_back(u);
}
void df... |
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
import bisect
test = int(input())
for _ in range(test):
h,c,t = map(int,input().split())
if t*2 <= (h+c):
print(2)
continue
l = 0
r = 100000000
while l+1 < r:
x = (l+r)//2
if (h*(x+1)+c*x) < t*(2*x+1):
r = x
else:
l = x
if abs(t*(2*l+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 sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(ro... |
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 solve(h, c, t):
if t * 2 <= (h + c): return 2
ans = 1
x = (c-t)//(h+c-2*t)
def den(x): return abs((2*x-1)*t-x*h-(x-1)*c)
def num(x): return 2*x-1
for i in range(x-5, x+5):
if i <= 0: continue
if den(i)*num(ans) < den(ans)*num(i): ans = i
#if floor(x) > 0 and f(floor(x)) < 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... | import java.io.*;
import java.util.*;
public class MixingWater {
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) {
long h = 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... | #include <bits/stdc++.h>
using namespace std;
int solve(long long int h, long long int c, long long int t) {
if (h == t) return 1;
if ((h + c) / 2.0 >= t) return 2;
long long int x = (h - t) / (2 * t - h - c);
long long int y = x + 1;
long double tx = (long double)(x * (h + c) + h) / (long double)(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 sys,math
Tests=int(input())
for _ in range(Tests):
h,c,t=map(int,sys.stdin.readline().split())
if h==t:
print(1)
else:
x=(h+c)/2
if x>=t:
print(2)
else:
k=(h-t)//(2*t-h-c)
if(abs((k*(h+c)+h)-(t)*(2*k+1))*(2*k+3)<=abs((... |
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,ceil
for _ in range(int(input())):
h,c,t = map(int,input().split())
if t > (h+c)/2:
k1 = floor((t-h)/(h+c-2*t))
k2 = ceil((t-h)/(h+c-2*t))
if abs(t*(2*k1+1)*(2*k2+1)-((k1+1)*h+k1*c)*(2*k2+1)) > abs(t*(2*k1+1)*(2*k2+1)-((k2+1)*h+k2*c)*(2*k1+1)):
print(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... | from math import *
# from collections import Counter,defaultdict,deque
# from bisect import bisect_left as bl, bisect_right as br
# from itertools import accumulate,permutations
# import heapq
# from functools import reduce
from io import BytesIO, IOBase
import sys
import os
# IO region
def Iint(): return 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.io.BufferedReader;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
public class CE88C {
public static void main(String[] args) throws NumberFo... |
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... | """
Code of Ayush Tiwari
Codeforces: servermonk
Codechef: ayush572000
"""
import sys
input = sys.stdin.buffer.readline
def solution():
for _ in range(int(input())):
# This is the main code
h,c,t=map(int,input().split())
bb=(h+c)/2
if t<=bb:
print(2)
els... |
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 deque
import sys
def input(): return sys.stdin.readline().rstrip()
for _ in range(int(input())):
h, c, t = list(map(int, input().split()))
if (2 * t == c + h):
print(2)
continue
base = abs(h - c) // abs(2*t - c - h)
ans = 0
d = 2e18
for i in range(bas... |
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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.io.BufferedWriter;
import java.math.MathContext;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatch... |
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 double pi = 3.14159265358979311599796346854;
long long mod = 998244353;
long long fast_exp(long long a, long long b) {
if (b <= 0)
return 1;
else {
long long res = 1;
res = fast_exp(a, b / 2);
res = (res * res) % mod;
if (b % 2 == 1) res =... |
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 egaeus
* @mail sebegaeusprogram@gmail.com
* @veredict Not sended
* @url <https://codeforces.com/problemset/problem/>
* @category ?
* @date 28/05/2020
**/
import java.io.*;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.*;
import static j... |
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 deque
import sys
def input(): return sys.stdin.readline().rstrip()
for _ in range(int(input())):
h, c, t = list(map(int, input().split()))
if (2 * t == c + h):
print(2)
continue
base = abs(h - c) // abs(2*t - c - h)
ans = 0
d = 2e18
for i in range(bas... |
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().strip())
eps = 1e-20
def diff(n):
return abs(((n+1)*h + n*c)/(2*n+1) - t)
def better(k, n):
return (2*k + 1) * abs((n+1)*(h-t) +n*(c-t) ) >= (2*n+1) * abs((k+1)*(h-t) + k*(c-t))
def strictlybetter(k, n):
return (2*k + 1) * abs((n+1)*(h-t) +n*(c-t) ) > (2*n+1) * abs((k+1)*(h-t) + 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... | t=int(input())
for i in range(t):
a=[]
a=list(map(int, input().split()))
h=a[0]
c=a[1]
t=a[2]
ans=0
m=2
ans=float(h)
ch=ans
if h<=t:
print(1)
elif (h+c)/2>=t:
print(2)
else:
while 0==0:
m+=2
ch=ans
... |
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;
template <class T>
inline void amin(T &x, const T &y) {
if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
if (x < y) x = y;
}
using ll = signed long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
const int INF... |
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.*;
public class Codechef {
PrintWriter out;
StringTokenizer st;
BufferedReader br;
class Pair implements Comparable<Pair>
{
int f;
int s;
Pair(int t, int r) {
f = t;
s = r;
}
public int compareTo(Pair p)
... |
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 fractions
def calc_temp(h, c, curr):
numerator = h * curr[0] + c * curr[1]
denominator = curr[0] + curr[1]
return fractions.Fraction(numerator, denominator)
def solve(h, c, t):
if h == t or t >= (c + 5 / 6 * (h - c)):
return 1
if t <= (h + c) / 2:
return 2
start = 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... | _ = int(input())
h=0
c=0
t=0
def fn(cnt):
return t*(2*cnt-1)-cnt*h-(cnt-1)*c
for __ in range(_):
h, c, t = [int(a) for a in input().split()]
if h+c >= t*2:
print(2)
continue
# if h == t:
# print(1)
# continue
l = 1
r = 1
while fn(r) < 0:
r *= 2
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 fractions import Fraction as f
for tc in xrange(input()):
H, C, T = map(int, raw_input().split())
ans = f(H + C, 2)
cups = 2
if abs(H - T) <= abs(ans - T):
ans = H
cups = 1
if H + C != 2 * T:
n = (T - H) / (H + C - 2 * T)
itr = max(0, n - 3)
while it... |
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 i in range(q):
h,c,t=list(map(int,input().split()))
if 2*t<=(h+c):
print(2)
else:
k=(h-t)/((2*t)-h-c)
m=int(k)
n=m+1
x=abs(((m+1)*h)+(m*c)-(((2*m)+1)*t))/((2*m)+1)
y=abs(((n+1)*h)+(n*c)-(((2*n)+1)*t))/((2*n)+1)
if x<=y:
p... |
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 _ 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
# print(x,y)
xx = ((x+1)*h+x*c)
yy = ((y+1)*h+y*c)
# print(xx,yy)
if xx*(2*y+1)+yy*(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... | for i in range(int(input())):
h,c,t=map(int,input().split())
if (h+c)/2>=t:
print(2)
else:
k=(h-t)//(2*t-h-c)
x = abs((k*(h+c)+h)-t*(2*k+1))*(2*k+3)
y = abs(((k+1)*(h+c)+h)-t*(2*k+3))*(2*k+1)
if y>=x:
print(2*k+1)
else:
print(2*k+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... | #include <bits/stdc++.h>
using namespace std;
long double h, c, t;
vector<pair<double, int> > pot;
void bs() {
long long lo = 0, hi = 1e9, mid;
long long bestN = -1;
long double bestDif = 1e9;
while (lo <= hi) {
mid = (lo + hi) / 2;
long double tmp = ((mid + 1) * h + mid * c) / (2 * (mid + 1) - 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... | // Utilities
import java.io.*;
import java.util.*;
public class Main {
static int T;
static int h, c, t;
static int k;
static double cmp1, cmp2;
public static void main(String[] args) throws IOException {
T = in.iscan();
while (T-- > 0) {
h = in.iscan(); c = in.iscan(); t = in.iscan();
if (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... | from __future__ import division, print_function
_interactive = False
def main():
def f(h, c, t, i):
return (h*(i+1) + c*i - t*(2*i+1))
def interpolation(h, c, t, st):
prev = st
i = 0
while True:
cur = st + 2**i
if f(h, c, t, cur) <= 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... | import java.util.*;
import java.io.*;
public class I {
public I(FastScanner in, PrintWriter out) {
int T = in.nextInt();
for (int i = 0; i < T; i++) {
long h = in.nextInt();
long c = in.nextInt();
long t = in.nextInt();
double minT = (h + c) / 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... |
import java.util.Scanner;
public class CF_1363_C {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int tc=sc.nextInt();
while(tc-->0) {
int h=sc.nextInt();
int c=sc.nextInt();
int t=sc.nextInt();
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... | from sys import stdin, gettrace
if not gettrace():
def input():
return next(stdin)[:-1]
# def input():
# return stdin.buffer.readline()
def main():
def solve():
h,c,t = map(int, input().split())
if t <= (h+c)/2:
print(2)
return
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... | for i in range(int(input())):
h,c,t = map(int,input().split())
if h+c>= 2*t:
print (2)
elif h==t:
print (1)
else:
x = int((t-c)/(2*t -h-c))
tb1 = abs((2*x-1)*t- ((h+c)*x-c))*(2*x+1)
tb2 = abs(t*(2*x+1) - ((h+c)*x+h))*(2*x-1)
if tb2 < tb1:
z = x+1 +x
else:
z = x + x-1
print(z) |
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(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
int c, h, t1;
cin >> h >> c >> t1;
int ans = 0;
if (t1 <= (c + h) / 2)
cout << 2 << endl;
else {
int a = h - t1;
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... | #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;
}
... |
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 eps = 1e-8;
const int maxn = 100000 + 5;
int h, c, t;
double fun(double x) {
return fabs((double)((x + 1) * h + (x)*c) / (double)(2 * x + 1) - (double)t);
}
int main() {
int T;
cin >> T;
while (T--) {
scanf("%d%d%d", &h, &c, &t);
int r, l;
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... | # Why do we fall ? So we can learn to pick ourselves up.
from decimal import *
getcontext().prec = 40
from math import ceil
t = int(input())
for _ in range(0,t):
h,c,t = map(int,input().split())
if h+c >= 2*t:
print(2)
else:
# x, x-1, error +- 10
num = t-c
den = 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 java.io.*;
import java.io.IOException;
import java.util.*;
//import javafx.util.Pair;
//import java.util.concurrent.LinkedBlockingDeque;
//import sun.net.www.content.audio.wav;
public class Codeforces {
public static long mod = (long)Math.pow(10, 9)+7 ;
public static doubl... |
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("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
using namespace std;
inline long long int addmod(long long int a, long long int b) {
return (a % 1000000007 + b % 1000000007) % 1000000007;
}
inline long long int s... |
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
testc = int(input())
def diff(h, t, c, n):
n = float(n)
curt = round((n * h + (n - 1) * c) / (2 * n - 1), 20)
return curt
for i in range(testc):
l = input().split()
h = float(l[0])
c = float(l[1])
t = float(l[2])
if(h == t):
print(1)
elif((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.buffer.readline
def print(val):
sys.stdout.write(str(val) + '\n')
def val(x,h,c):
return (h-c)/(2*(x*2 -1))
def prog():
for _ in range(int(input())):
L = 1
R = 10**12
h,c,t = map(int,input().split())
if t <= (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... | """ 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... | # -*- coding: utf-8 -*-
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
INF = 2**62-1
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
def re... |
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 n) { return abs(t - (h + (h + c) * n) * 1.0 / (2 * n + 1)); }
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int nTest = 0;
cin >> nTest;
while (nTest--) {
cin >> h >> c >> t;
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... | 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)
if abs(v1-(2*x+1)*t)/(2*x+1)<=abs(t*(2*x+3)-v2)/(2*x+3):
print(2*x+1)
else:
... |
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
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97 # a
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return [int(i) for i in input().split()]
def lcm(a, b): return abs(a * b) // math.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... | #include <bits/stdc++.h>
using namespace std;
long long check(long long n, long long m, long long x, long long y) {
return x >= 0 && x < n && y >= 0 && y < m;
}
void pr() { cout << '\n'; }
template <class A, class... B>
void pr(const A &a, const B &...b) {
cout << a << (sizeof...(b) ? " " : "");
pr(b...);
}
templ... |
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
import bisect
from sys import stdin, stdout
from itertools import repeat
import math
# sys.stdin = open('input')
def inp(force_list=False):
re = map(int, raw_input().split())
if len(re) == 1 and not force_list:
return re[0]
return re
def inst():... |
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 N = 2e5 + 10, mod = 1e9 + 7;
int h, c, t;
long double get(int x) {
long double cur = ((x / 2) + (x % 2)) * 1ll * h + (x / 2) * 1ll * c;
cur /= x;
return cur;
}
int main() {
int tc = 1;
scanf("%d", &tc);
for (int cn = 1; cn <= tc; cn++) {
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... | from decimal import *
getcontext().prec = 28
def solve():
if h == c:
return 1
if (h + c) // 2 >= t:
print(2)
return
ans = bs(1, 10 ** 6)
a1 = getdif(ans)
a2 = getdif(ans - 1)
if abs(t - a1) < abs(t - a2):
print(2 * ans - 1)
else:
ans -= 1
pri... |
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(mid):
return (mid + 1) * h + mid * c >= t * (2 * mid + 1)
t = int(input())
for _ in range(t):
h, c, t = map(int, input().split())
if 2 * t <= h + c:
print(2)
continue
if h <= t:
print(1)
continue
ok = 0
ng = 10 *... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.