description stringlengths 35 9.39k | solution stringlengths 7 465k |
|---|---|
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.MathContext;
import java.text.*;
public class C1359 {
static int c, h, t;
static long ans;
static BigDecimal best;
static double eps = 0;
public static void solve(long k) {
BigDecimal bc = BigDecimal.valueOf(c);
BigDecimal 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;
int main() {
long long int t;
cin >> t;
while (t--) {
long long int h, c, T;
cin >> h >> c >> T;
if (h == T) {
cout << 1 << endl;
continue;
} else if ((h + c) >= 2 * T) {
cout << 2 << endl;
} else {
long long int x, y;
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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, c, h, t;
cin >> T;
while (T--) {
cin >> h >> c >> t;
if (2 * t <= h + c)
cout << "2" << endl;
else {
if (t == h)
cout << "1" << endl;
else {
double n;
n = (double)(h - t) / (2 * t - h - c);
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... |
def getCups(h,c,t,x):
x = round(x)
minDiff = (100000000000,1)
cups = -100
for i in range(int(x)-1-2, int(x)+2+2):
# print(i)
if i % 2 == 1:
# v = (h*((i+1)/2) + c*((i-1)/2))/i
v = (h*((i+1)/2) + c*((i-1)/2), i)
else:
v = ((h+c)/2, 1)
diff = (abs(v[0]-t*i), i)
# print(i, abs(v-t))
if diff[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 sys
import math as mt
from decimal import *
getcontext().prec = 50
input=sys.stdin.buffer.readline
def cal(i,c,h):
return (Decimal(i*(c+h)+h)/Decimal((2*i)+1))
t=int(input())
#t=1
for __ in range(t):
#n=int(input())
#l=list(map(int,input().split()))
h,c,temp=map(int,input().split())
#print(... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 <typename T>
void read(T &n) {
n = 0;
T f = 1;
char c = getchar();
while (!isdigit(c) && c != '-') c = getchar();
if (c == '-') f = -1, c = getchar();
while (isdigit(c)) n = n * 10 + c - '0', c = getchar();
n *= f;
}
template <typename T>
void write(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... | /*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking inte... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 <typename T>
void write(vector<T> &a) {
for (auto it = a.begin(); it != a.end(); it++) cout << *it << " ";
cout << "\n";
}
void random(long long int nMin, long long int nMax, long long int n) {
srand(time(0));
for (long long int i = 0; i < n; i++) {
dou... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 M = 1e9 + 7;
void solve() {
long long h, c, t;
cin >> h >> c >> t;
double ans = h - t;
long long taken = 1;
if (abs((h + c + 0.0) / 2 - t) <= ans) {
ans = abs((h + c + 0.0) / 2 - t);
taken = 2;
}
double y = (h - t + 0.0) / (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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
static void init(InputStream 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... | #include <bits/stdc++.h>
using namespace std;
int main() {
int T;
long long h, c, t, lo, hi, mid, l;
scanf("%d", &T);
for (int tc = 0; tc < T; tc++) {
scanf("%lld%lld%lld", &h, &c, &t);
if ((t << 1) <= h + c)
printf("2\n");
else {
lo = 0;
hi = 500005;
while ((hi - lo) > 1) {
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
T = int(input())
for _ in range(T):
h,c,t = map(int,input().split())
if (2*t<=h+c):
print(2)
else:
A = (h-t)//((2*t)-h-c)
k = 2*A+1
Ans = 100000000000
ans = 0
for i in range(k+3,k-1,-1):
A = abs((((i+1)//2)*h+(i//2)*c)-t*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... | import sys
from fractions import Fraction
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')
def calc(x, 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... | """
____ _ _____
/ ___|___ __| | ___| ___|__ _ __ ___ ___ ___
| | / _ \ / _` |/ _ \ |_ / _ \| '__/ __/ _ \/ __|
| |__| (_) | (_| | __/ _| (_) | | | (_| __/\__ \
\____\___/ \__,_|\___|_| \___/|_| \___\___||___/
"""
"""
░░██▄░░░░░░░░░░░▄██
░▄▀░█▄░░░░░░░░▄█░░█░
░█░▄░█▄░░░░░░▄█░▄░█░
░█░███████... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | // practice with kaiboy
import java.io.*;
import java.util.*;
public class CF1359C extends PrintWriter {
CF1359C() { super(System.out); }
Scanner sc = new Scanner(System.in);
public static void main(String[] $) {
CF1359C o = new CF1359C(); o.main(); o.flush();
}
void main() {
int q = sc.nextInt();
while (q... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class DE3 {
static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] Args){
FastReader scan=new FastReader();... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.util.*;
public class solution {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int t=scan.nextInt();
for(int tt=0;tt<t;tt++) {
long h=scan.nextInt(), c=scan.nextInt(), target=scan.nextInt();
long l=-1, r=100000000L;
while (r-l>1) {
long mid=(r+l)/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... | for _ in range(int(input())):
h,c,t = list(map(int, input().split()))
av = (h+c)/2
if(t >= h):
print(1)
continue
elif(t<=av):
print(2)
continue
x = (h-t)//(2*t - (h+c))
t1 = ((x+1)*h + x*c)
t2 = ((x+2)*h + (x+1)*c)
if(abs(t*(2*x+1)-t1)*(2*x+3) <= abs(t*(2*... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
const long long mod = 1e9 + 7;
vector<bool> prime(MAX, 1);
vector<int> spf(MAX, 1), primes;
void sieve() {
prime[0] = prime[1] = 0;
spf[2] = 2;
for (long long i = 4; i < MAX; i += 2) {
spf[i] = 2;
prime[i] = 0;
}
primes.push_back(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... |
def mix(high, low, n, target):
upp = abs((n + 1) * high + n * low - target * (2 * n + 1))
low = 2 * n + 1
return [upp, low]
def solve(high, low, target):
if 2 * target <= high + low:
print(2)
return
left = 0
right = 1000 * 1000 * 1000 * 1000
while right - left > 30:
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
using namespace std::chrono;
using namespace std;
long long mul(long long a, long long b, long long m = 1000000007) {
long long res = 0;
a = a % m;
while (b > 0) {
if (b % 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;
mt19937_64 mt(time(0));
long long gcd(long long a, long long b) {
if (a > b) swap(a, b);
if (a == 0) return b;
return gcd(b % a, a);
}
pair<long long, long long> get_res(long long a, long long b, long long n,
long long c) {
long lo... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from sys import stdin,stdout
input=stdin.readline
def print(x):
stdout.write(str(x)+'\n')
def solve():
h,c,t=map(int,input().split())
if t<=(h+c)/2:
print(2)
else:
k=(h-t)//(2*t-h-c)
k=2*k+1
c1= (k//2+1)*h + (k//2)*c - t*k
c2= ((k+2)//2+1)*h + ((k+2)//2)*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... | inp = lambda cast=int: [cast(x) for x in input().split()]
printf = lambda s='', *args, **kwargs: print(str(s).format(*args), flush=True, **kwargs)
t, = inp()
for _ in range(t):
h, c, t = inp()
if 2*t <= h+c:
print(2)
else:
x = (t-c)//(2*t-h-c)
y = x+1
res1 = (x*h + (x-1)*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... | #: Author - Soumya Saurav
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq,sys,io, os, time
from decimal import Decimal
start_time = time.time()
ONLINE_JUDGE = __debug__
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... | import math
t = int(input())
for _ in range(t):
h, c, t = map(int, input().split())
t3 = (h + c) / 2
if t == c or 2 * t <= h + c:
print(2)
elif t == h:
print(1)
elif t3 == t:
print(2)
else:
x1 = int((h - t) / (2 * t - h - c))
x2 = x1 + 1
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... | def cups(x,h,c,t):
error = (x+1) * h + x * c - t * (2*x+1)
return abs(error)
def f(h,c,t):
if (h+c) >= 2*t:
return 2
x = (h-t) // (2*t-h-c)
e1 = cups(x,h,c,t)
e2 = cups(x+1,h,c,t)
if e1 * (2*x+3) <= e2 * (2*x+1):
return 2*x+1
else:
return 2*x+3
T = int(input())
for t in ra... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from sys import stdin
import math
from decimal import *
from fractions import Fraction
getcontext().prec=50
a = int(stdin.readline())
for b in range(0, a):
A = stdin.readline().split()
h = int(A[0])
c = int(A[1])
t = int(A[2])
if (c + h) == 2 * t:
print(2)
continue
if (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... | t=int(input())
for _ in range(t):
h,c,t=map(int,input().split())
avg=(h+c)/2
if t==h:
print(1)
continue
if avg>=t:
print(2)
continue
else:
n1=int((t-c)/(2*t-h-c))
n2=2*t*(2*n1-1)*(2*n1+1)
n3=((n1-1)*(c+h)+h)*(2*n1+1)+(n1*(c+h)+h)*(2*n1-1)
if(n2>=n3):
print(2*n1-1)
else:
print(2*n1+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;
int32_t main() {
long long t;
cin >> t;
while (t--) {
long long c, h;
cin >> h >> c;
long long y;
cin >> y;
if (y >= h) {
cout << 1 << endl;
} else if (2 * y <= (c + h)) {
cout << 2 << endl;
} else {
long long a = (2 * y) ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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;
const int inf = 1e9;
const double eps = 2e-6;
int h, c, t;
double f(ll i) { return abs(t - (h * (i + 1) + c * i) / (2.0 * i + 1)); }
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin >> T;
while (T--) {
cin >... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.IOException;
import java.io.InputStreamReader;
import java.io.BufferedOutputStream;
import java.io.UncheckedIOException;
import java.nio.charset.Charset;
import java.util.StringTokenizer;
imp... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | # t1: h = (h+c)/2 + (h-c)/2
# t2: (h+c)/2
# t3: (2h+c)/3 = (h+c)/2 + (h-c)/6
# t4: (h+c)/2
# t5: (3h+2c)/5 = (h+c)/2 + (h-c)/10
# t6: (h+c)/2
# output 1: (h+c)/2 + (h-c)(1/(1x3)) <= t <= h
# output 3: (h+c)/2 + (h-c)(2/(3x5)) <= t < ...
# output 5: (h+c)/2 + (h-c)(3/(5x7)) <= t < ...
# output 7: (h+c)/2 + ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | n =int(input())
while n>0:
n-=1
h,c,t = map(int,input().split())
# temp = h
# k=1
# for i in range(10):
# if k%2:
# temp+=c
# else:
# temp+=h
# k+=1
# print(k,temp/k)
if(t>=h):
print(1)
elif t<=(h+c)/2:
print(2)
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;
float h, c, t;
float helper(int a) { return (a * h + (a - 1) * c) / (2 * a - 1); }
void solve() {
cin >> h >> c >> t;
if (t == h) {
cout << "1\n";
return;
}
if (t <= (h + c) / 2) {
cout << 2 << "\n";
return;
}
long long int low = 1LL, high = 1e9;... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 asize = 1005;
long double c, h, t, m, two = 2.0, three = 3.0, x;
long double hotonbase(long double v) {
long double cups = 1 + (2 * v), total = (h + c) * v + h;
return total / cups;
}
long double bs() {
long double ans = 0;
for (int i = 61; i >= 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 math
test = int(input())
for _ in range(test):
h,c,t = map(int, input().split())
if t==h:
print(1)
elif t <= (h+c)//2:
print(2)
else:
l = 1
r = 2**31 -1
flag = True
while(l<r):
mid = (l+r)//2
if ((h+c)*mid+h)==t*(2*mid+1):
print(2*mid+... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from sys import stdin, stdout
input = lambda: stdin.readline().strip()
fast_print = stdout.write
from math import sqrt, floor, ceil
from bisect import bisect_right
def dist(n, h, c, t):
return abs((n*h+(n-1)*c)-t*(2*(n)-1))
T = int(input())
for _ in range(T):
h, c, t = map(int, input().split())
if h==t:
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long h, c, t;
cin >> h >> c >> t;
if ((h + c) / 2 >= t) {
cout << 2 << '\n';
return;
}
long long k = 2 * ((t - h) / (h + c - 2 * t)) + 1;
long long val2 = abs((k + 2) / 2 * c + (k + 3) / 2 * h - t * (k + 2)) * k;
long long val1 = ab... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
from functools import cmp_to_key
input = sys.stdin.readline
def main():
tc = int(input())
def cmp(a, b):
dif = a[0] * b[1] - a[1] * b[0]
return dif if dif != 0 else a[1] - b[1]
cmp = cmp_to_key(cmp)
ans = []
for _ in range(tc):
h, c, t = map(int, input().split(... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 judge(x):
return (2*x+1)*h+x*(c-h)>=t*(2*x+1)
def binary_search():
l, r = 0, 10**18
while l<=r:
m = (l+r)//2
if judge(m):
l = m+1
else:
r = m-1
return r
T = int(input())
for _ in range(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... | import math
t=int(input())
for _ in range(t):
h,c,t=map(int,input().split())
if (h==t):
print(1)
continue
ans1=(h+c)/t
if ((h+c)/2>=t):
print(2)
continue
ans2=0
if (ans1==int(ans1)):
print(int(ans1))
else:
ans2=(t-h)//(h+c-2*t)
op1=ans2
op2=ans2+1
t1=((h+c)*op1+h)
t2=((h+c)*op2+h)
d1=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... | #include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long h, c, t;
long double calc(long long x) {
long double th = x * h + x * c;
th /= (2 * x);
return abs(th - t);
}
long long ternary_search(long long lo, long long hi) {
while (lo < hi - 2) {
long long m1 = (lo * 2 + hi) / 3;
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
import string
input = sys.stdin.readline
import math
#import numpy
#letters = list(string.ascii_lowercase)
from decimal import Decimal
l = int(input())
for i in range(l):
n = list(map(int, input().split()))
a,b = n[0] - n[1], n[2] - n[1]
#print(a,b)
try:
s = int(2/(2 - 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... | for _ in range(int(input())):
h,c,t=map(int,input().split())
if t<=(h+c)/2:print(2)
else:
k=(h-t)//(2*t-h-c)
if abs((2*k+3)*t-k*h-2*h-k*c-c)*(2*k+1)<abs((2*k+1)*t-k*h-h-k*c)*(2*k+3):print(2*k+3)
else:print(2*k+1)
|
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict as dd
def main():
for _ in range(int(input())):
h,c,t=map(int,input().split())
if t<=(h+c)/2: print(2)
else:
n=(c-t)//(h+c-2*t)
if abs(n*(h+c)-c-t*(2*n-1))*(2*n+1)>abs((n+1)*(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... | /**
* @author derrick20
*/
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) {
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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())):
p=0
a,b,c=map(int,input().split())
d=[]
h=0
t=0
e=[]
if a<=c and b<=c:
print(1)
elif 2*c-a-b<=0:
print(2)
else:
k=(a-c)//(2*c-a-b)
if abs(k*(a+b)+a-c*(2*k+1))*(2*k+3)<=abs((k+1)*(a+b)+a-c*(2*k+3))*(2*k+1):
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.io.*;
import java.util.*;
public class C implements Runnable {
boolean oj = false;
Reader scn;
PrintWriter out;
String INPUT = "";
void solve() {
int t = scn.nextInt();
while (t-- > 0) {
int hot = scn.nextInt(), cold = scn.nextInt(), temp = scn.nextInt();
if (temp == hot) {
out.println(... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 = 18
for t in range(int(input())):
n,m,k=map(int,input().split())
l=1
r=10**9
while r-l>3:
mid=(r+l)//2
if mid%2==0:
mid-=1
'''if mid%2==0:
c=mid//2
chk=((c*n)+(c-1)*m)/(mid-1)
if chk<k:
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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
flush = sys.stdout.flush
for _ in range(int(input())):
h, c, t = map(int, input().split())
m = h + c >> 1
if t <= m:
print(2)
continue
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... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.Random;
import java.util.StringTokenizer;
public class C {
//Solution by Sathvik Kuthuru
public static void main(String[] args) {
FastReader scan = new FastReader();
PrintWriter out = new PrintWriter(System.out);
Task solver = new Task();
int 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 tt in range(int(input())):
h, c, t = map(int, input().split())
if t <= (h + c) // 2:
print(2)
else:
num = int((t - h) / (h + c - 2 * t))
num = 2 * num + 1
if num % 2:
op1 = num
op2 = num + 2
c1 = abs(((op1 // 2 + 1) * h + (op1 // 2) * 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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.function.Function;
import java.io.Writer;
import java.io.Outp... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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
t = int(input())
for _ in range(t):
h,c,t = map(int, input().split())
if t <= (h+c)/2:
print(2)
continue
if h<t:
print(1)
continue
amt=1
k=500000//2
while k>0:
while ((amt+k)*h + ((amt+k)-1)*c) > t * ((amt+k)+(amt+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... | from __future__ import division
from sys import stdin
out = []
for _ in range(int(input())):
h, c, t = map(int, stdin.readline().split())
d1, d2 = h - t, t - c
if d1 >= d2:
out.append(2)
else:
lo = (c - t) // (h + c - 2 * t)
hi = lo + 1
tem1 = abs((lo * h + (lo - 1) * c... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
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... | from fractions import Fraction as F
from math import isclose
for _ in range(int(input())):
h, c, t = map(int, input().split())
if 2 * t <= h + c:
print(2)
continue
def f(hot):
return (hot * h + (hot-1) * c)
def g(hot):
return abs(t - F(hot * h + (hot-1) * c, hot * 2 - 1))
lo = 1
hi = 10 ** 9
while lo... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from decimal import Decimal
from math import floor
from sys import stdin, stdout
int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class C1359 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(n... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int h, c, t;
cin >> h >> c >> t;
if (t <= c) {
cout << 2 << "\n";
continue;
}
if (t >= h) {
cout << 1 << "\n"
<< "\n";
continue;
}
double val1, val2, val3, 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 math
from decimal import Decimal as d
def calcT(th, tc, n):
return (d((tc * n)) + ((n+1) * th)) / ((2*n) + 1) # Added Decimal function
def main(th, tc, t):
if (th + tc)/2 >= t: return 2
else:
n = (t - th)/(tc + th - (2 * t))
# Comparing the ceil and floor values of n
if 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... | import math
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 = math.ceil(m)
m2 = math.floor(m)
if(abs(((m2+1)*h+m2*c)-(2... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 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... | from sys import stdin, stdout
# 30, 10, 20
# (30x + 10y) / (x + y) = 20
# x = y || x = y+1
# 40x / 2x = 20
# (30x + 10x - 10) / (2x - 1) = 20
# (10x + 30x - 30) / (2x - 1) = 20
# (40x - 10) / (2x - 1)
# 40x/(2x-1) - 10/(2x-1)
# 40x/(2x-1) - 30/(2x-1)
# (30x + 10(x - 1)) / (2x - 1)
def mixing_water(h, c, t):
r... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | /**
* @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.util.*;
import static java.lang.Integer.*;
import stat... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | for _ in range(int(input())):
h, c, t = map(int, input().split())
if h==t:
print(1)
elif (t-c<=h-t):
print(2)
else:
temp = (t-h)/(h+c-2*t)
if (int(temp)==temp):
print(int(2*temp+1))
else:
a = int(temp)
b = 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):
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... | import sys
from collections import defaultdict as dd
import heapq
import math
try:
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
except:
pass
input = sys.stdin.readline
for i in range(int(input())):
h,c,t=map(int,input().split())
l=t-(h+c)/2
if t==h:
print(1)
elif 2*t<=(h+c):
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 java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class test2{
public static void main (String [] args) throws IOException
{
try {
Scanner sc=new Sca... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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
T = int(input())
for _ in range(T):
h, c, t = map(int, input().split())
if h + c >= 2 * t:
print(2)
else:
diff2 = 2*t - (h + c)
hDiff2 = 2*h - (h + c)
kDown = (hDiff2//diff2 - 1)//2
kUp = kDown + 1
diffDown = abs(diff2 -... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 ecr88;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
public class C {
InputStream is;
PrintWriter out;
String INPUT = "";
void solve(... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 bisect import *
from collections import *
from math import gcd,ceil,sqrt,floor,inf
from heapq import *
from itertools import *
from operator import add,mul,sub,xor,truediv,floordiv
from functools import *
#------------------------------------------------------------------------
import os
import sys
from io impor... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 string
input = sys.stdin.readline
import math
#import numpy
#letters = list(string.ascii_lowercase)
from decimal import Decimal
l = int(input())
for i in range(l):
n = list(map(int, input().split()))
a,b = n[0] - n[1], n[2] - n[1]
#print(a,b)
try:
s = int(2/(2 - 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... | import sys
from fractions import Fraction
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in r... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
impor... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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())
s = []
for i in range(T):
s.append(input())
for i in range(T):
h, c, t = map(int,s[i].split())
if t == h:
n = 1
elif t <= (h+c)/2:
n = 2
else:
k = (c-t)/(h+c-2*t)
n = int(2*k-1)
if n%2 == 0:
n = n+1
k = (n+1)/2
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
T = input()
while(T>0):
h,c,t = map(int, raw_input().split())
if ((h + c) == 2*t):
print 2
else:
x = (c - t)/float(h + c - 2*t)
count2 = math.ceil(x)
count1 = math.floor(x)
# print count1, count2
diff1 = abs(t - (h*count1 + c*(count1 - 1))/(2*count1 - 1))
diff2 = abs(t - (h*count2 + 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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
static void init(InputStream 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 sys
import os.path
import math
if __name__ == '__main__':
if os.path.isfile("in.txt"):
sys.stdin = open("in.txt", "r", encoding="utf-8")
for _ in range(int(input())):
h, c, t = map(int, input().split())
if t >= h:
print(1)
elif t < h and 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.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();
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 fractions import Fraction
def eq(A, B, x):
return Fraction(x * (A+B) - B, 2 * x - 1)
def main():
t = int(input())
for _ in range(t):
A,B,C= [int(x) for x in input().split()]
if (A+B) / 2 == C:
if A-C <= ((A+B) / 2) - C:
print('1')
else:
print('2')
else:
best_x = (B-C) / (A +... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from fractions import Fraction as F
def solve():
h, c, t = map(int, input().split())
dt = abs(F(h - t))
ans = 1
def update(u, v):
nonlocal dt, ans
if u <= 0 or v < 0:
return
w = F(u * h + v * c, u + v)
if abs(w - t) < dt:
dt = abs(w - t)
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
double h, c, tt;
cin >> h >> c >> tt;
if (2 * tt <= h + c) {
cout << "2"
<< "\n";
continue;
}
long long r = (h - tt) / (2 * tt - h - c);
long long s = r + 1;
double r1... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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,os
from io import BytesIO, IOBase
from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
from fractions import Fraction
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in r... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | numcases = int(input())
for _ in range(numcases):
h, c, t = map(int, input().split())
ans = 0
minc = float('inf')
if h + c != t*2:
diff = t - h
change_diff = t*2 - (h + c)
if diff > 0 and change_diff < 0 or diff < 0 and change_diff > 0:
mindiff = abs(diff)//abs(change... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
/**
* @author Tran Anh Tai
* @template for CP codes
*/
public class ProbC {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long tt;
cin >> tt;
while (tt--) {
float h, c, t, tot, x2;
float d1 = 0.0, d2 = 0.0, a = 0.0, min = 100000000, diff = 0;
long long i;
cin >> h >> c >> t;
a ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
from math import inf
input = sys.stdin.readline
def prog():
for _ in range(int(input())):
h,c,t = map(int,input().split())
lowest = (h+c)/2
if t <= lowest:
print(2)
elif abs(t-(2*h+c)/3) >= abs(t-h):
print(1)
else:
closest = (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... | for _ in range(int(input())):
h,c,t=[int(c) for c in input().split()]
if t <= (h + c)/2:
print(2)
else:
##finding k
a=h-t
b=2*t - h-c
k=2*(a//b) +1
# k = ( t - h) // (h+c - 2*t)
##comparing k and k + 1
a =abs((k//2)*c + ((k+1)//2)*h -... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | for test_ in range(int(input())):
h, c, t = map(int, input().split())
if t <= (h + c) // 2:
print(2)
else:
t -= (h + c) / 2
t1 = ((h - c) / 2) / t
x1, x2 = int(((t1 - 1) // 2) * 2 + 1), int(((t1 + 1) // 2) * 2 + 1)
if (h - c) / (x1 * 2) - t <= t - (h - c) / (x2 * 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... | # https://codeforces.com/problemset/problem/1359/C
import sys
import os
import heapq
import math
try:
path = "./file/input.txt"
if os.path.exists(path):
sys.stdin = open(path, 'r')
# sys.stdout = open(r"./file/output.txt", 'w')
except:
pass
T = int(input())
def printd(value):
# print... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | // Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
import java.io.*;
public class C_Mixing_Water{
public static void main(String[] args) {
FastRea... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
tc = int(input())
ans = [0] * tc
for ti in range(tc):
h, c, t = map(int, input().split())
if abs(3 * t - (h + c + h)) >= abs(3 * t - 3 * h):
ans[ti] = 1
continue
if h +... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... |
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import static java.lang.Math.abs;
import static java.lang.Math.ceil;
/* tutorial solution much better*/
public class Main {
public st... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 -*-
"""
Created on Fri May 29 13:34:56 2020
@author: default
"""
#%%
def count(h, c, t):
if h+c >= 2*t:
ans = 2
else:
k = int((h - t) / (2*t - h - c))
if 4*k*(k+1)*(h+c)+(6*k+5)*h+c*(2*k+1) <= 2*t*(2*k+1)*(2*k+3):
ans = 2*k + 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 java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
// HashMap<> map=new HashMap<>();
// TreeMap<> map=new TreeMap<>();
// map.put(p,map.getOrDefault(p,0)+1);
// for(Map.Entry<> mx:map.entrySet()){
// int v=mx.getValue(),k=mx.getKey();
// }
// ArrayList<Pai... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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())
for testCase in range(t):
h, c, t = [int(_) for _ in input().split()]
if h == t:
print(1)
elif t <= (h+c)/2:
print(2)
else:
sumTemp = h+c
minGuess = 0
maxGuess = 555555
while maxGuess-minGuess > 1:
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | def solve():
[hi, lo, barrel] = map(int, input().split())
if 2 * barrel <= hi + lo:
return 2
items = (hi - barrel) // (2 * barrel - hi - lo)
temp = lambda t: (((t + 1) * hi + t * lo) - (2 * t + 1) * barrel) / (2 * t + 1)
if abs(temp(items)) > abs(temp(items + 1)):
items += 1
retu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.