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... | FAST_IO = 0
if FAST_IO:
import io, sys, atexit
rr = iter(sys.stdin.read().splitlines()).next
sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
@atexit.register
def write():
sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().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 java.util.Scanner;
public class er88c3 {
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... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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())
for i in range(n):
read = input().split(' ')
a = float(read[0])
b = float(read[1])
c = float(read[2])
if c == a:
print(1)
elif abs(c - (a + b)/2) == 0:
print(2)
else:
k = abs(c-a)/abs(a+b-2*c)
k = int(2*k + 1)
# print(k)
avr = ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.MathContext;
import java.math.RoundingMode;
import java.util.StringTokenizer;
public class P1359C {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputRead... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.MathContext;
import java.util.*;
public class A implements Runnable {
FastReader sc;
PrintWriter out;
void solve()
{
int tc = sc.ni();
outer: while(tc-- > 0)
{
long h = sc.nl();
long c = sc.nl();
long t = sc.nl();
double 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.util.Scanner;
/**
* @εε»ΊδΊΊ YDL
* @εε»ΊζΆι΄ 2020/5/9 22:34
* @ζθΏ°
*/
public class Main {
private static manyFunc<Integer,Long> f= (n,h,l)->((long)(h+l)*n-l);
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int len = sc.nextInt();
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
#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 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 C_Mixing_Water {
public static void main(String[] args) {
MyScanner sc = new MyScanner();
PrintWriter 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... | import math
for i in range(int(input())):
h, c, t = map(int, input().split())
if (h + c) / 2 >= t:
print(2)
continue
if h <= t:
print(1)
continue
left = 1
right = 1000000000
while right - left > 1:
n = (right + left) // 2
temp_1 = (n * h + (n - 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 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... | #include <bits/stdc++.h>
using namespace std;
vector<long long int> pr;
void SieveOfEratosthenes() {
long long int n = 1000000;
bool prime[n + 1];
memset(prime, true, sizeof(prime));
for (long long int p = 2; p * p <= n; p++) {
if (prime[p] == true) {
for (long long int i = p * p; i <= n; i += p) prim... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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;
long long bs() {
long long lo = 0, hi = 1e17, 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);
long double error = abs(tm... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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- Akshit Monga'''
from fractions import Fraction
q=int(input())
for _ in range(q):
h,c,t=map(int,input().split())
if 2*t<=(h+c):
print(2)
else:
x1 = (c - t) // (h + c - 2 * t)
x2=x1+1
if abs(t-Fraction((x1*h+(x1-1)*c),(2*x1-1))) <= abs(t-Fraction((x2*h+(x2-1)*c),(2*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... | def solve(th, tc, t):
ans = 0
if th == t:
ans = 1
elif 2*t <= th + tc:
ans = 2
else:
# halfsum = (th + tc)/2
# halfdelta = (th - tc)/2
# k = halfdelta/(t - halfsum)
k = (th - tc)/(2*t - th - tc)
if (th - tc)%(2*t - th - tc) == 0:
if k%2... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int checktemp(double temp1, double temp2, double t) {
if (abs(temp1 - t) > abs(temp2 - t))
return 1;
else
return 0;
return 0;
}
int main() {
int w;
cin >> w;
while (w--) {
float h, c, t;
cin >> h >> c >> t;
if (t <= (h + c) / 2) {
cout ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | // Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class c
{
static class FastReader
{
BufferedReader br;
StringTokenizer 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... | import java.util.*;
import java.io.*;
public class Main {
static FastReader in = new FastReader();
public static void main(String[] args) {
int t = in.nextInt();
while (t-- > 0) solve();
}
static void solve() {
int h = in.nextInt(), c = in.nextInt(), t = in.nextInt(), 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 java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class Solution {
static long h,c,te;
static long binary(){
long l=1,r=(long)1e7;
while(l<=r){
if(r-l<5){
double min=h-te;
long ans=1;
for(long i=l;i<=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... | #include <bits/stdc++.h>
using namespace std;
void mycode();
const long long int mod = 998244353;
long long int ceil(long long int a, long long int b) { return (a + b - 1) / b; }
long long int min(long long int a, long long int b) {
if (a > b)
return b;
else
return a;
}
bool bit_check(long long int a, int i... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | for _ 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)-c-t*(2*n+1))*(2*n-1):
print(2*n+1)
else: print(2*n-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 dx[] = {0, -1, 0, 1, 0, 0}, dy[] = {-1, 0, 1, 0, 0, 0},
dz[] = {0, 0, 0, 0, -1, 1};
const long long N = 1e5 + 7;
long long n, m, p;
inline long long read() {
long long first = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.InputStreamReader;
import java.util.StringTokenizer;
public class Prob3 {
public static void main(String[] args) {
FastReader fr = new FastReader();
int q = fr.nextInt();
for (int o=0; o<q; o++) {
int t1 = fr.nextInt();
int t2 = fr... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.math.*;
import java.io.*;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.text.DecimalFormat;
import java.lang.Math;
import ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
void solve() {
long long h, c, t;
cin >> h >> c >> t;
if (h == t) {
cout << 1 << '\n';
return;
}
if (h + c >= t * 2) {
cout << 2 << '\n';
return;
}
long long lo = 0, hi = 1e7;
while (lo < hi) {
int m = (lo + hi + 1) / 2;
if (m * (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... | from sys import stdin
input=lambda : stdin.readline().strip()
from math import ceil,sqrt,factorial,gcd
for _ in range(int(input())):
h,c,t=map(int,input().split())
m=abs(t-(h+c)/2)
ans=2
if m>abs(t-0):
ans=0
if 2*t-h-c!=0:
z=(h-t)/(2*t-h-c)
b=abs(t-(ceil(z)*(h+c)+h)/(2*ceil(z)+1))
a=abs(t-(int(z)*(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;
double mi, kq, h, c, t, q;
void xuly(long long x) {
if (x < 0) return;
double tg = abs(t - (x * (h + c) + h) * 1.0 / (2 * x + 1));
if (mi > tg || (mi == tg && kq > x * 2 + 1)) {
mi = tg;
kq = x * 2 + 1;
}
}
int main() {
cin >> q;
while (q--) {
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 math
tt = int(input())
for test in range(tt):
h,c,t = map(int,input().split())
if t<=(h+c)/2: print(2)
else:
k = (h-t)//(2*t-h-c)
if 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)
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... | import sys
import math
import heapq
import collections
def inputnum():
return(int(input()))
def inputnums():
return(map(int,input().split()))
def inputlist():
return(list(map(int,input().split())))
def inputstring():
return([x for x in input()])
def inputmatrix(rows):
arr2d = [[j for j in input().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... | import sys
from collections import defaultdict
import math
input = sys.stdin.readline
def print_result(l): return print(' '.join(map(str, l)))
def timer(function):
import time
def wrapper(*args, **kwargs):
t1 = time.time()
val = function()
t2 = time.time()
print("Executed \... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 = list(map(int, input().split()))
av = (h+c)/2
if h == c:
print(1)
elif t <= av:
print(2)
else:
d = (t-av)/(h-av)
# sk = 1
# while 1/sk >= d:
# sk += 2
# print("sk is {}".format(sk))
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 math
t = int(input())
for x in range(t):
[h,c,t]=list(map(int,input().split()))
if t <= (h+c)/2:
print(2)
else:
y = (t-c)/(2*t-h-c)
#print(y)
y1 = int(y)
y2 = y1 + 1
#print(2*y1-1)
#print(2*y2-1)
z1 = abs((h*y1+c*(y1-1))*(2*y2-1)-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 sys
import math
import collections
def set_debug(debug_mode=False):
if debug_mode:
fin = open('input.txt', 'r')
sys.stdin = fin
def bs(m):
return -t * (2 * m - 1) + (m * h + (m-1) * c)
if __name__ == '__main__':
# set_debug(True)
t = int(input())
for ti in range(1, 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 java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileRe... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.StringTokenizer;
public cla... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, -1, 0, 1};
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long q;
cin >> q;
while (q--) {
long long h, c, t;
cin >> h >> c >> t;
if (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 sys,math,random
input=sys.stdin.readline
import sys,math,random
input=sys.stdin.readline
T=int(input())
for _ in range(T):
n,m,t=map(int,input().split())
diff=abs(t-((n+m)/2))
fv=2
if (t==n):
print(1)
elif (2*t==(n+m)):
print(2)
else:
val=(n-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 h+c-2*t >= 0:
print(2)
else:
a = h - t
b = 2*t - c - h
k = 2 * (a // b) + 1
val1 = abs(k // 2 * 1 * c + (k + 1) // 2 * 1 * h - t * 1 * k)
val2 = abs((k + 2) // 2 * 1 * c + (k + 3) // 2 * 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>
using namespace std;
long long h, c, t, lo, hi;
long double cal(long long mid) {
long double a = 1.0 * h * (mid + 1) + 1.0 * c * mid;
a /= 2.0 * mid + 1;
return a;
}
int main() {
int tc;
cin >> tc;
while (tc--) {
cin >> h >> c >> t;
if (h == t)
cout << 1 << '\n';
e... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import fractions
f=fractions.Fraction
tests=int(input())
for _ in range(tests):
h,c,t=map(int,input().split())
av1=(h+c)/2
if (h+c)/2 == t:
print(2)
else:
x=(t-h)/(h+c-2*t)
if x<0:
if abs(h-t)<=abs(t-av1):
print(1)
continue
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import io
import os
import math
def solve(H, C, T):
# Need big decimal for more floating point resolution but TLEs
assert C < H
assert C <= T <= H
if H == T:
return 1
# After even (2 * i) cups, average is always (H + C) / 2
# After odd (2 * i + 1) cups, average is ((i + 1) * H + i * 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.util.*;
public class Main {
public static void main(String args[])
{
FastReader input=new FastReader();
PrintWriter out=new PrintWriter(System.out);
int T=input.nextInt();
while(T-->0)
{
long h,c,t;
h=input.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... | T = int(input())
for _ in range(T):
h, c, t = map(int, input().split())
if h <= t:
print(1)
elif t <= (h + c) // 2:
print(2)
else:
i1 = (t - h) // (h + c - 2 * t)
i2 = i1 + 1
if ((i1+1) * h + i1 * c) * (2*i2 + 1) + ((i2+1) * h + i2 * c) * (2*i1 + 1) <= 2 * 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;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
double t, c, h;
long long x, y;
cin >> y;
for (long long i = 0; i < y; i++) {
cin >> h >> c >> t;
x = 1 / (1 - 2 * (t - h) / (c - h));
if (x < 0 || (c + h) == 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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class CF1359C {
public static void main(String[] args) {
FastReader input = new FastReader();
int t = input.nextInt();
while (t > 0){
long hot = ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 Main extends PrintWriter {
private void solve() {
int T = sc.nextInt();
for(int tt = 1; tt <= T; tt++) {
long h = sc.nextLong();
long c = sc.nextLong();
long t = sc.nextLong();
if(h+c >= 2L*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 sys
input = sys.stdin.readline
T = int(input())
def solve(h, c, t, x):
if (h*x + c*(x - 1)) > t * (2 * x - 1):
return True
else:
return False
for _ in range(T):
h, c, t = [int(x) for x in input().split()]
left = 1
right = 10**20
while right - left > 1:
mid = (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.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.InputMismatchException;
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Random;
import java.util.StringTokenizer;
public class MixingWater {
static final int MAXN = 1000_006;
stati... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 = (t-c)//(2*t-h-c)
v1 = ((x)*h + (x-1)*c)
v2 = ((x+1)*h + (x)*c)
if abs(v1-(2*x-1)*t)/(2*x-1)<=abs(t*(2*x+1)-v2)/(2*x+1):
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 java.io.*;
import java.util.StringTokenizer;
public class Main {
FastScanner in;
PrintWriter out;
public static void main(String[] args) throws Exception {
(new Main()).run();
}
private void run() throws Exception {
in = new FastScanner(System.in);
out = new PrintWr... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class SolutionD extends Thread {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new 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... | from decimal import *
getcontext().prec = 100
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 * ((am... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;
public class cf1359_Div2_C {
public static double solve(double mid, int h, int c) {
return ((mid * h) + (mid - 1) * c) / (2 * mid - 1);
}
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
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;
long long int MOD = 998244353;
long long int mod = 1e9 + 7;
long long int INF = 1e18;
long long int dx[] = {1, -1, 0, 0};
long long int dy[] = {0, 0, 1, -1};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t;
cin >> t;
while (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... | cases = int(input())
for _ in range(cases) :
hot, cold, target = map(int, input().split())
if 2 * target <= hot + cold :
print(2)
elif target >= hot :
print(1)
else :
lo, hi = 1, 10**20
while lo < hi :
mid = (lo+1+hi) // 2
if mid * hot + (mid-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
input = sys.stdin.readline
def getInts():
return [int(s) for s in input().split()]
def getInt():
return int(input())
def getStrs():
return [s for s in input().split()]
def getStr():
return input().strip()
def listStr():
return list(input().strip())
import collections as col
im... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | for _ in range(int(input())):
a,b,c=map(int,input().split())
mid=(a+b)/2
if c==a:
print(1)
elif c<=mid:
print(2)
elif c>=(mid+(a-b)/6) and c<a:
d=(mid+(a-b)/6)
if abs(d-c)<abs(a-c):
print(3)
else:
print(1)
else:
c-=mid
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | def cck(val, h, c, t):
return (val+1)*h+val*c < t*(2*val+1)
def cnt(val, h, c):
return (val+1)*h+val*c
ts = int(raw_input())
for cs in range(ts):
h, c, t = tuple(map(int, raw_input().split()))
if(2*t <= h+c):
print 2
continue
st, ed = 0, 1000000000000
while st+1 < ed:
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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... | import java.io.*;
import java.util.*;
import java.lang.*;
public class Rextester{
public static void main(String[] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int z = Integer.parseInt(br.readLine());
StringBuffer sb = new StringBuffer()... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import java.util.*;
public class Main {
static Set<Long> set = new TreeSet<>();
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int TC = s.nextInt();
tc: for (int tc = 0; tc < TC; tc++) {
int h = s.nextInt();
int c = s.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:
print(2)
elif t>=h:
print(1)
else:
x=2*t-h-c
k=(h-c+x)//(2*x)
test1=abs((8*k**2-2)*t-(h*k+c*k-c)*(4*k+2))
test2=abs((8*k**2-2)*t-(h*(k+1)+c*(k+1)-c)*(4*k-2))
test3=abs((8*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 java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.List;
import java.util.*;
public class realfast implements Runnable
{
private static final int INF = (int) 1e9;
long in= (long)Math.pow(10,9)+7;
long fac[]= new long[3000];
publ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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/contest/1359/problem/C
def calc(a, b, t, k):
num1, num2 = abs(k*(a+b)+a - (2*k + 1)*t), abs((k+1)*(a+b) + a - (2*k + 3)*t)
den1, den2=(2*k + 1), (2*k + 3)
if num1*den2 <= num2*den1:
return 2*k + 1
return 2*k + 3
t=int(input())
for _ in range(t):
a, b, t=map(int, 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... | tt = int(input())
for _ in range(tt):
h, c, t = list(map(int, input().split(' ')))
if t>=h:
print(1)
elif t <= (c+h)/2:
print(2)
else:
n = (t-c)/(2*t-h-c)
m = int(n)+1
nn = int(n)
e = (nn*h+(nn-1)*c) - t*(2*nn-1)
ee = t*(2*m-1) - (m*h+(m-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... | from fractions import Fraction
def temp(hot, cold, step):
return Fraction((hot * step + cold * (step - 1)), (2 * step - 1))
tests = int(input())
for i in range(tests):
numbers = input().split(" ")
h = int(numbers[0])
c = int(numbers[1])
t = int(numbers[2])
if t >= h:
print(1)
el... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | from math import ceil, floor
from decimal import Decimal
def calculate(x, y, n):
return Decimal(x * n + y * (n - 1)) / Decimal(2 * n - 1)
def ca(x, y):
return (x + y) / 2
for _ in range(int(input())):
x, y, c = map(int, input().split())
ans1 = 2
if (x + y) / 2 >= c:
print(ans1)
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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,temp = map(int,input().split())
ave_temp = (h+c)/2
if temp <= ave_temp:
print(2)
elif h == temp:
print(1)
else:
u = (h-c)/((temp-ave_temp)*2)
u_l = int(u)
if int(u) % 2 == 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.math.BigInteger;
import java.util.*;
public class Main {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
static int MOD = 1000000007;
public static void main(String[] args) throws IOException {
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 main():
from decimal import Decimal
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
T = int(input())
for _ in range(T):
h, c, t = [Decimal(x) for x in input().strip().split()]
avg = (h + c) / 2
if h == t:
print(1)
continue
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
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));
long long val1 = abs(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 java.io.*;
import java.util.*;
import java.math.*;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class MixingWater {
public static void main(String[] args) throws IOException {
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... | # Nilfer
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 java.util.*;
import java.io.*;
public class MixingWater
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
OutputStream outputStream = System.out;
PrintWriter out = new PrintWriter(outputStream);
int T;
T=in.nextInt();
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long i, T, n;
cin >> T;
while (T--) {
double h, c, t, ans;
cin >> h >> c >> t;
double res = h, freq = 1.0, diff = fabs(((h + c) / 2) - t);
if (h == t) {
cout << 1 << "\n";
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import math
import sys
from fractions import Fraction
input = sys.stdin.readline
ts = int(input())
# (h + c) * n / 2n = (h + c) / 2
# ((h + c) * n + h) / (2n + 1) = (h + c) * n/(2n + 1) + h/(2n + 1)
res = []
for cs in range(ts):
h, c, t = map(int, input().split())
if 2 * t <= (h + c):
res.append(2)
else:
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 math
from sys import stdin,stdout
import sys
import fractions
mod=1000000007
F=fractions.Fraction
t=int(stdin.readline())
while t>0:
h,c,tt=list(map(int,stdin.readline().split()))
mini=sys.maxsize
ans=0
xx=[]
if(2*tt>h+c):
xx.append((h-tt)//((2*tt)-(h+c)))
xx.append((h-tt)//((... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import 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... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using v2 = vector<vector<T>>;
template <typename T>
inline v2<T> fill(int r, int c, T t) {
return v2<T>(r, vector<T>(c, t));
}
int h, c, t;
ll calc(int n) { return (ll)h * (n + 1) + (ll)c * n; }
void solv... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 X>
ostream& operator<<(ostream& x, const vector<X>& v) {
for (long long i = 0; i < v.size(); ++i) x << v[i] << " ";
return x;
}
template <typename X>
ostream& operator<<(ostream& x, const set<X>& v) {
for (auto it : v) x << it << " ";
return 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.*;
import java.util.*;
public class F {
public static void main(String[] args) throws Throwable {
Scanner sc = new Scanner();
PrintWriter pw = new PrintWriter(System.out);
int T = sc.nextInt();
while (T-- > 0) {
h = sc.nextInt();
c = sc.nextI... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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
# from collections import defaultdict, deque
# from math import log10, sqrt, ceil
# from pprint import pprint
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]
from functools import lru_cache
from itertools import pro... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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
import bisect
import math
#i = bisect.bisect_left(a, k)
#list=input().split(maxsplit=1)
def sol(x,y,z):
p=(x+y)/2
p=p-z
p*=2
kk=(y-x)/p
return kk
for xoxo in range(1):
#a=[]
for _ in range (int(input())):
#n=int(input())
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... | import java.io.*;
import java.util.*;
public class C {
void solve() throws IOException {
in = new InputReader("__std");
out = new OutputWriter("__std");
int testCount = in.readInt();
for (int test = 1; test <= testCount; ++test) {
long h = in.readInt();
lon... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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
import math
def main():
pass
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mo... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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.math.*;
public class C {
public static void main(String []args) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String input;
String []splited;
int q,n,m,t;
int []arr,arr1;
int[][... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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
t1 = int(input())
while t1:
t1 += -1
h, c, t = map(int, input().split())
if h == t: print(1)
elif h + c >= 2 * t: print(2)
else:
x = (c - h) // (h + c - 2 * t)
mn = 9999999999999999999
ans = 0
for i in range(max(1, x - 10), x + 10):
... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t;
cin >> t;
while (t--) {
long long h, c, t;
cin >> h >> c >> t;
if (t == h) {
cout << "1" << '\n';
continue;
}
if (2 * t <= h + c) {
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.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
public class MixingWater {
public static void main(String[] args) {
FastReader reader = new FastReader();
BufferedWriter log = new Buf... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | import sys
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')
class Q:
def __init__(self, p, q=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>
struct Drob {
long long a, b;
Drob(long long a = 0, long long b = 0) : a(a), b(b) { ; }
bool operator<(const Drob& other) const {
return (a * other.b) < (b * other.a);
}
Drob operator-(const Drob& other) const {
return Drob(a * other.b - other.a * b, b * other.b);
}
};
Drob ... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long mx = 2e6 + 10;
int posx[] = {1, -1, 0, 0};
int posy[] = {0, 0, 1, -1};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long t = 1, n, k, m, a, b, c, d, h;
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... | def rs(): return input().strip()
def ri(): return int(input())
def ria(): return list(map(int, input().split()))
def ia_to_s(a): return ' '.join([str(s) for s in a])
def temp_at_2k_1(h, c, k):
return k * h + (k - 1) * c, 2 * k - 1
def solve(h, c, t):
if t <= (h+c)//2:
return 2
k_left = 1
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 java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
public class Main {
private static final String NO = "NO";
private static fina... |
There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the 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 MainClass
{
static ArrayList<Long> val = new ArrayList<>();
public static void main(String[] args)throws IOException
{
Reader in = new Reader();
StringBuilder stringBuilder = new StringBuilder();
int t = in.nextInt();
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... | #include <bits/stdc++.h>
using namespace std;
using ii = pair<unsigned long long, unsigned long long>;
using ll = long long;
const double EPS = 1e-9;
bool equals(double a, double b) { return fabs(a - b) < EPS; }
int32_t main() {
ios::sync_with_stdio(0);
unsigned long long t;
cin >> t;
while (t--) {
double 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;
long long int MOD = 1000000007;
long long int MX = 400000000000000000;
long long int T, t, h, c;
int main() {
ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
cin >> T;
while (T--) {
cin >> h >> c >> t;
if (2 * t == h + c) {
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... | 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:
diff=t-x
some=int(abs((c-h)//(2*diff)))
if(some%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... | T = int(input())
o = []
for i in range(T):
h, c, t = input().split()
h = int(h)
c = int(c)
t = int(t)
s = (h + c) / 2
if t >= h:
o.append(1)
elif t <= s:
o.append(2)
else:
i = (h - t) / (2 * t - (h + c))
#print(i)
if i == int(i):
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 decimal import *
input=sys.stdin.buffer.readline
def temp(nHot,h,c): #assuming that nCold=nHot-1
return (nHot*h+(nHot-1)*c)/(2*nHot-1)
def tempDec(nHot,h,c): #for higher precision
return Decimal(nHot*h+(nHot-1)*c)/(2*nHot-1) #for more precision
nTests=int(input())
for _ in range(nTests)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.