description
stringlengths
35
9.39k
solution
stringlengths
7
465k
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import sys, random, math from bisect import bisect_left, bisect_right input = sys.stdin.readline def main(): inf = 10 ** 20 t = int(input()) # t, a, b = map(int, input().split()) # t = 1 for _ in range(1, t+1): # print("Case #{}: ".format(_), end = '') h, c, t = map(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...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; int T; cin >> T; for (int i = 0; i < T; i++) { long long h, c, d; cin >> h >> c >> d; if (d == h) { cout << "1" << "\n"; } else if (d <= (h + c) / 2) { cout << "2" ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
#!/usr/bin/env python3 t = int(input()) for _ in range(t): h, c, t = map(int, input().split()) if t >= h: print(1) continue if (h + c) % 2 == 0 and t == (h + c) // 2: print(2) continue if t < (h + c) / 2: print(2) continue # $$ t = (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 long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } int tt; long long h, c, t; long long k, a, b; int main() { scanf("%d", &tt); while (tt--) { scanf("%lld%lld%lld", &h, &c, &t); if (t <= (h + c) / 2) puts("2\n"); else { 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...
def abc(i,j,c): global a,b ans=i while i<=j: mid = i+(j-i)//2 if (mid*b+(mid+1)*a)<=c*(2*mid+1): ans=mid i=mid+1 else: j=mid-1 return ans def bca(i,j,c): global a,b ans=i while i<=j: mid = i+(j-i)//2 if (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...
import sys from collections import defaultdict as dd from collections import deque from fractions import Fraction as f def eprint(*args): print(*args, file=sys.stderr) zz=1 from math import * import copy #sys.setrecursionlimit(10**6) if zz: input=sys.stdin.readline else: sys.stdin=open('input.txt', 'r') sys.std...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import fractions for _ in range(int(input())): h,c,t = list(map(int,input().split())) if(h-t>=t-c): print(2) else: mind = abs(t-h) ans = 1 tavg = (h+c+1)//2 if(abs(t-tavg)<mind): ans = 2 l = 1 r = 10**9 F = fractions.Fraction ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 a, b, r; cin >> a >> b >> r; if (a == r) { cout << "1" << endl; } else { double avg = (a + b) / double(2); if (r <= avg) { cout << "2" << endl; } else { long long val1 = ceil(double(abs(r - a)) / abs(a + b - 2 * 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...
for test in range(int(input())): h, c, t = map(int, input().split()) if h == t: print(1) elif t <= (h + c) / 2: print(2) elif abs(t - h) <= abs(t - (2 * h + c) / 3): print(1) else: x = ((h - t) // (2 * t - h - c)) y = x + 1 dif2 = abs((2*y+1)*t-y*h-y*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> const int mod = 1000000007; const long long INF = 9000000000000000000; using namespace std; void solve() { double lb, ub, temp, x, y; cin >> ub >> lb >> temp; double H, L, mid; H = ub, L = (lb + ub) / 2; mid = (ub + ub + lb) / 3; if (temp >= H) cout << 1 << endl; else if (temp...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
t=int(input()) for i in range (t): s=input().split() h=int(s[0]) c=int(s[1]) te=int(s[2]) if te==h: print("1") elif h-te==te-c: print("2") else: sum=c+h if h-te>te-c: print("2") else : a=h-te b=sum-2*te...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; inline int read() { register int x; register char c(getchar()); register bool k; while ((c < '0' || c > '9') && c ^ '-') if ((c = getchar()) == EOF) exit(0); if (c ^ '-') x = c & 15, ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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.PrintWriter; import java.math.BigInteger; import java.util.Arrays; import java.util.Random; import java.util.Scanner; import static java.lang.Math.abs; public class C_rational { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); PrintWrite...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 z[300005]; signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long t; cin >> t; while (t--) { long long h, c, t; cin >> h >> c >> t; if (h + c >= 2 * t) { cout << 2 << endl; } else if (h == t) cout << 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 Main { private static final boolean N_CASE = true; private void solve() { long h = sc.nextInt(); long c = sc.nextInt(); long t = sc.nextInt(); if (2 * t <= h + c) { out.println(2); return; } ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
def check(h, c, k, l, t): if(l == -1): return abs(((k+1)*h+k*c)/(2*k+1)-t) T = abs(((k+1)*h+k*c)-t*(2*k+1))*(2*l+1)-abs(((l+1)*h+l*c)-t*(2*l+1))*(2*k+1) return T # print(check(41,15,2,30)) def solve(h, c, t): m1 = abs((h+c)//2-t) if(t <= (h+c)//2): return 2 left = 0 right ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int N = 2e6 + 1; const long long INF = 9e18; const int M = 2e3 + 5; void solve() { long long h, c, t; cin >> h >> c >> t; if ((h + c) >= t * 2) { cout << 2 << '\n'; return; } long long l = 0, r = 1e6; while ((r - l) >= 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 input = sys.stdin.buffer.readline for nt in range(int(input())): h,c,t=map(int,input().split()) m=(h+c)/2 if m>=t: print (2) continue if h<t: print (1) continue # h*x + c*(x-1) = t*(2*x-1) # x*(h+c)=2tx-t+c # t-c=x*(2t-h-c) m=10**18 x = (t-c)/(2*t-h-c) # print (x) for i in range(max(1,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...
/* * * @Author Ajudiya_13(Bhargav Girdharbhai Ajudiya) * Dhirubhai Ambani Institute of Information And Communication Technology * */ import java.util.*; import java.io.*; import java.lang.*; public class Code38 { public static void main(String[] args) { InputReader in = new InputReader(System.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=[int(i) for i in input().split()] if t<=(h+c)/2: print(2) else: l=1 r=10**12 mid=(l+h)/2 while l<r: mid=(l+r)//2 sum=(h*(mid)+c*(mid-1))/(2*mid-1) #print(mid,sum) if sum>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; bool desc(int a, int b) { return (a > b); } bool pairone(pair<int, int> &a, pair<int, int> &b) { return (a.first < b.first); } void show(vector<int> vec) { for (auto x : vec) cout << x << " "; cout << endl; ; } double tn(double h, double c, int n) { if (n % 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...
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...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { double h, c, t; cin >> h >> c >> t; if (h == t) { cout << 1 << "\n"; } else if (2 * t <= h + c) { cout << 2 << "\n"; } else { int x = (c - t) / (h + c - (2 * t)); int y = x + 1; ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
T=int(input()) for _ in range(T): h,c,t=map(int,input().split()) d=10**9 if t<=(h+c)/2: print(2) continue k=(h-t)//(2*t-h-c) a=abs((k*(h+c)+h)-(2*k+1)*t)*(2*k+3) b=abs(((k+1)*(h+c)+h)-(2*k+3)*t)*(2*k+1) print([2*k+1,2*k+3][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...
tq=int(input()) for x in range(tq): m,x,y=list(map(int,input().split())) if ((m+x)/2>=y): print(2) else: #(k+1)*m+k*x=(2*k+1)*y k=(m-y)//(2*y-m-x) ta=((k+1)*m+k*x)*(2*k+3) tb=((k+2)*m+(k+1)*x)*(2*k+1) #print((ta-y)*10**6,(tb-y)*10**6,y) if (abs(tb-y*(2...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
#include <bits/stdc++.h> using namespace std; #pragma GCC target("sse4.2") long long gcd(long long n, long long m) { if (n == 0) return m; return gcd(m % n, n); } bool ifprime(long long n) { if (n == 1) return false; long long i; for (i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return tr...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); } long long int power(long long int a, long long int 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 mpow(int base, int exp); void ipgraph(long long n, long long m); void dfs(int u, int par); const int mod = 1000000007; const int N = 3e5, M = N; vector<long long> g[N]; double calc(long long x, double h, double c) { return ((c + h) * x + h) / (2 * x + 1); } int main()...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 gcd(long x,long y){ if(y==0) return x; return gcd(y,x%y); } static long binary(){ long l=1,r=(long)1e7; while(l<=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> const long double pi = 3.1415926536; using namespace std; long double hot, cold, t; long double avg(long double x, long double y) { return (long double)(x + y) / 2.0; } long double f(int i) { return (long double)(i * hot + (i - 1) * cold) / (long double)(2.0 * i - 1); } void solve() { 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...
#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 a = h - t; long long b = 2 * t - h - c; long long k = 2 * (a / b) + 1; long long val2 = abs((k + 2) / 2 * 1ll * c + (k + 3) / 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() { long long int t; cin >> t; while (t--) { long double h, c, k, sum = 0, x, l = 1, g = 1, d, y, s, r, q, o; cin >> h >> c >> k; if (h == k) cout << "1\n"; else { sum = (h + c) / 2; s = abs(sum - k); if (sum == 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...
def temp(h,c,cups,k): if cups%2==0: return (h+c)//2; n=cups//2; return abs((h+c)*n+h-k*cups),cups; def lessthanore(a,b): return a[0]*b[1]<=a[1]*b[0]; def check(n,k,h,c): correct=abs(temp(h,c,2*n+1)-k); before=abs(temp(h,c,2*n-1)-k); after=abs(temp(h,c,2*n+3)-k); pr...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import java.awt.*; import java.io.*; import java.lang.reflect.Array; import java.util.*; public class Abc { public static void main(String[] args) throws Exception { FastReader sc = new FastReader(); int tt=sc.nextInt(); while (tt-->0){ int h=sc.nextInt(),c=sc.nextInt(),t=sc.nex...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
#include <bits/stdc++.h> using namespace std; const int N = 1005; char g[N][N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { long double h, c, t; cin >> h >> c >> t; if (t >= h) { cout << "1\n"; continue; } if ((h + c) / 2 >= t) { ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import math num_cases = int(input()) for _ in range(num_cases): li = input().strip().split() h,c,t = [int(i) for i in li] diff = abs((h+c)/2 - t) if (h==c): print(1) elif (diff==0): print(2) else: n = (t-c)/abs(h+c-2*t) n1 = max(1,int(n)) n2 = max(1,math.ceil(n)) diff1 = abs(((h+c-2*t)*n1 - c + 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; void solve() { int h, c, d; cin >> h >> c >> d; long double avg = (h + c) / 2; long double even = abs((long double)d - avg); long double temp, temp1; long double odd = 1ll << 60, odd1 = 1ll << 60; if ((2 * d - h - c) <= 0) { cout << "2" << "\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 t=int(input()) for _ in range(t): h,c,t=map(int,input().split()) even_last=h+c-t*2 if(even_last>=0): print(2) else: a=h-t b=2*t-(h+c) k=(2*(a//b)+1) v1=abs((k//2*c+(k+1)//2*h)-k*t) v2=abs(((k+2)//2*c+(k+3)//2*h)-(k+2)*t) if(v1*(k+2)<=v2...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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(x) for x in input().split()] if t==h: print(1) elif (h+c)/2>=t: print(2) else: m=int((t-c)/(2*t-c-h));temp=abs((m*(h+c-2*t)+t-c)/(2*m-1));temp1=abs(((m+1)*(h+c-2*t)+t-c)/(2*(m+1)-1)) print(2*m-1 if temp<=temp1 else 2*m+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 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)) - 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...
# ------------------- fast io -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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...
from fractions import Fraction T = int(input()) for _ in range(T): H,C,T = map(int,input().split()) if T*2 <= H+C: print(2) continue else: def is_ok(k): return T*(2*k-1) <= H*k + C*(k-1) ok = 1 ng = 10**18 while ng-ok > 1: m = (ok+ng)//...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 * def more_precise(t, C, h, r): return abs(Decimal(t - C) - Decimal((h - C) / r)) def get_closer(t, C, h, r1, r2): d1 = abs(t - (C + ((h - C) / r1))) d2 = abs(t - (C + ((h - C) / r2))) #print(r1, r2, d1, d2, d1 == d2) if d1 == d2: d1 = more_precise(t, 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...
import sys from decimal import * input=sys.stdin.buffer.readline 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): h,c,t=[int(zz) for zz in input().split()] #Observe that for every nHot==nCold (nCups/...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import fractions def calc_temp(h, c, curr): numerator = h * curr[0] + c * curr[1] denominator = curr[0] + curr[1] return fractions.Fraction(numerator, denominator) def solve(h, c, t): if h == t or t >= (c + 5 / 6 * (h - c)): return 1 if t <= (h + c) / 2: return 2 start = 1 ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): h, c, t = map(int, input().split()) if t*2<=h+c: print(2) continue f = lambda x: x*h + (x-1)*c ok = 1 ng = 10**6 while abs(ok-ng)>1: mid = (ok+ng)//2 if f(mid)>=t*(mid*2-1): ok =...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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()) s = (h + c) / 2 if s >= t: print(2) continue s = t - s a = (h - c) / (2 * s) k = int((a + 1) // 2) if (h - c) / (4 * k - 2) - s <= s - (h - c) / (4 * k + 2): print(2 * k - 1) else: pri...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import sys input = sys.stdin.readline from fractions import * def go(mid, h, c): return Fraction(h * mid + c * (mid - 1), mid + mid - 1) MAX_HI = 3010101 def solve_case(input_text): h, c, t = map(int, input_text.rstrip().split()) if Fraction(h + c, 2) >= t: return 2 lo, hi = 1, MAX_HI ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
for _ in range(int(input())): h,c,t=map(int,input().split()) if(h==t): print(1) else: avg=(h+c)/2 if(avg==t): print(2) elif(avg>t): print(2) else: dif=(t-avg) j=int(abs((c-h)//(2*dif))) if(j%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...
def ab(a,b): if a>b: return a-b return b-a def abc(a): if a>=0: return a return -a for _ in range(input()): h,c,t=map(int,raw_input().split()) h-=c;t-=c; if (2*t)<=(h): print 2 continue p=(h-t)*(1.0)/(2*t-h) if p==(int(p)): print int(2*p+1);con...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 defaultdict as dd from collections import deque import bisect import heapq def ri(): return int(input()) def rl(): return list(map(int, input().split())) def solve(): h, c, t = rl() h, c, t = h - c, 0, t - c if 2*t <= h: print (2) return elif 6 * 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.*; import java.io.IOException; import java.util.*; //import javafx.util.Pair; //import java.util.concurrent.LinkedBlockingDeque; //import sun.net.www.content.audio.wav; public class Codeforces { public static long mod = (long)Math.pow(10, 9)+7 ; public static doubl...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
from fractions import Fraction as f for tc in xrange(input()): H, C, T = map(int, raw_input().split()) ans = f(H + C, 2) cups = 2 if abs(H - T) <= abs(ans - T): ans = H cups = 1 if H + C != 2 * T: n = (T - H) / (H + C - 2 * T) for itr in range(max(0, n - 2), n + 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...
# -*- coding: utf-8 -*- import sys from collections import defaultdict, deque def input(): return sys.stdin.readline()[:-1] # warning not \n # def input(): return sys.stdin.buffer.readline()[:-1] from fractions import Fraction as F # sys.setrecursionlimit(int(1e8)) def f(h, c, m, t): return h * (m + 1) + c * m ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
#include <bits/stdc++.h> using namespace std; float avg1(long long int n, long long int h, long long int c) { return (float)((n + 1) * h + (n - 1) * c) / (2 * n); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int tt; cin >> tt; for (int pp = 0; pp < tt; pp++) { long l...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
#include <bits/stdc++.h> using namespace std; int main() { int test; scanf("%d", &test); while (test--) { float h, c, t; scanf("%f %f %f", &h, &c, &t); if (h == t) { printf("1\n"); } else if (2 * t <= h + c) { printf("2\n"); } else { int x = (t - c) / (2 * t - c - h); 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 from decimal import * t = int(input()) def tg(h, c, x): return Decimal(h+((h+c)*x))/Decimal((2*x)+1) for _ in range(t): h, c, t = map(int, input().split()) # print(Decimal((t-h)/(h+c-(2*t)))) if h == t: print(1) elif (h+c)/2 >= t: print(2) else: x = ma...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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.*; import java.io.BufferedReader; import java.io.InputStreamReader; public class First { public static void main(String[] args) { InputStream inputStream = System.in; O...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 * from bisect import * from math import * from heapq import * from fractions import * import sys input=sys.stdin.readline t1=int(input()) while(t1): t1-=1 h,c,t=map(int,input().split()) if(h==t): print(1) continue try: x=(c-t)/(h+c-(2*t)) except: ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 from sys import exit for _ in range(int(input())): h, c, t = map(int, input().split()) # h, c, t = map(int, '41 15 30'.split()) if t >= h: print(1) continue # n = int(input()) # arr = list(map(int, input().split())) sr = Fraction(h + c, 2) 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...
def f(x): return abs(((x-1)*(c+h)+h)/(2*x-1)-temp) t=int(input()) for you in range(t): l=input().split() h=int(l[0]) c=int(l[1]) temp=int(l[2]) if(temp<=(c+h)/2): print(2) elif(temp>=h): print(1) else: poss=int((temp-c)/(2*temp-h-c)) num1=2*temp*(2*poss-1)*(2*poss+1) num2=((poss-1)*(c+h)+h)*(2*poss+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 from fractions import Fraction def dist(x, y): return abs(x-y) for _ in range(int(input())): h, c, t = map(int, input().strip().split()) c0 = (c-t)/(h+c-2*t) if h+c != 2*t else 0 c1 = max(int(math.ceil(c0)), 1) c2 = max(int(math.floor(c0)), 1) x1 = (dist(t, Fraction(h+c, 2)),...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class q3 { public static void main(String[] args) { FastReader s = new FastReader(); int t = s.nextInt(); while(t-- > 0) { long h = s.nextInt(); long 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...
from fractions import Fraction import sys input = sys.stdin.readline t=int(input()) g= [list(map(Fraction,input().split())) for i in range(t)] ans=[0]*t for i in range(t): h=g[i][0] c=g[i][1] x=g[i][2] if x>=h: ans[i]=1 elif x<=(h+c)/2: ans[i]=2 else: l = -1 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...
for _ in range(int(input())): h,c,t=map(int,input().split()) if(h==t): print(1) else: xx=(h+c)/2 if(xx==t): print(2) elif(xx>t): print(2) else: dif=(t-xx) j=int(abs((c-h)//(2*dif))) if(j%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...
#include <bits/stdc++.h> using namespace std; const int MOD = 998244353; const long long mod = 1e9 + 7; const int mxN = 5e5 + 9; void solve() { long long x, y, z; cin >> x >> y >> z; vector<pair<double, long long> > ans; ans.push_back(make_pair((double)abs(z - ((x + y) / 2)), 2)); long long A = y - z; long ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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; ll power(ll x, ll y); const ll MOD = 1000000007; double h, c, t; int f() { if (2 * t <= h + c) return 2; int L = 1, R = h, M; while (L <= R) { M = (L + R) / 2; if (((h + c) * M - c) / (2 * M - 1) > t) L = M + 1; else R = M...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import java.util.*; import java.io.*; public class GFG { public static void main (String[] args) { Scanner sc=new Scanner(System.in); PrintWriter out=new PrintWriter(System.out); int t1=sc.nextInt(); while (t1-->0){ long h=sc.nextLong(); long c=sc.nextLong(); long t=sc.nextLong(); 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...
for i in range(int(input())): h,c,t=map(int,input().split()) bb=(h+c)/2 if t<=bb: print(2) else: k= (h-t)/(2*t-h-c) k=int(k) 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+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; const long long INF = 1e9 + 7; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long T; cin >> T; while (T--) { long double h, c, t; cin >> h >> c >> t; if (t == h) { cout << 1 << "\n"; continue; } ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
from sys import stdin, stdout from decimal import * cin = stdin.readline cout = stdout.write for _ in range(int(cin())): h, c, t = map(int, cin().split()) if max((h+c)/2, t) - min((h+c)/2, t) <= 1e-6: cout('2\n') continue i = (c-t) // (h+c-t-t) if i <= 0: cout('2\n') continue diff = Decimal(max(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...
def check(h,c,x,t): return abs((x*(h+c-2*t)+t-c)/(2*x-1)) def answer(h,c,t): avg=(h+c)//2 if t<=avg: return 2 x=(t-c)//(2*t-h-c) if check(h,c,x,t)<=check(h,c,x+1,t): return 2*x-1 else: return 2*x+1 t=int(input()) for i in range(t): h,c,t=map(int,input()....
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.io.InputStreamReader; import java.io.FileOutputStream; import java.io.IOException; import java.util.StringTokenizer; public class MixingWater{ public static void main(String[] args)throws IOException{ 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...
#include <bits/stdc++.h> using ll = long long; using ull = unsigned long long; using ld = long double; using namespace std; int mod = 1000000007; int fact(int n) { int res = 1; for (int i = 2; i <= n; i++) { res = (res * 1ll * i) % mod; } return res; } int binpow(int x, int y) { int res = 1; x = x % mod...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 Solution { public static void main(String[] args) { final Scanner in = new Scanner(System.in); final int T = in.nextInt(); for (int t = 0; t < T; t += 1) { final long h = in.nextLong(); final long c = in.nextLong(); ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
#debugging c1.py #conceptual error hai mera - cant compare floats directly #see # >>> loss(499979, hot, cold, desired_temp) # 2.0000734366476536e-06 # >>> loss(499981, hot, cold, desired_temp) # 2.0000734366476536e-06 # asli mei the numbers may be different import sys def input(): return sys.stdin.readline().rstr...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 codfor { public static void main(String[] args) { Scanner s = new Scanner(System.in); int T = s.nextInt(); while (T-- > 0) { int h = s.nextInt(), c = s.nextInt(), t = s.nextInt(); if (2*t <= h+c) { System.out.println(2); 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; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long int tc, h, c, t; cin >> tc; while (tc--) { cin >> h >> c >> t; if (h + c >= 2 * t) cout << 2 << "\n"; else { long long int k = (t - h) / (h + c - 2 * t); ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
from sys import stdin, stdout from decimal import Decimal cin = stdin.readline cout = stdout.write #getcontext().prec = 50 for _ in range(int(cin())): h, c, t = map(int, cin().split()) if (h+c)/2 >= t: cout('2\n') continue i = (c-t) // (h+c-t-t) if abs(t - Decimal(h*i + c*(i-1))/Decimal(i+i-1)) <= abs(t - De...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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()) while T>0: T-=1 h,c,t=map(int,input().split()) if 2*t<=h+c: print(2) continue 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...
from decimal import * getcontext().prec = 30 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)) #p...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
// 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 java.util.*; import java.io.*; public class Main { static FastReader in=new FastReader(); static StringBuilder Sd=new StringBuilder(); static List<Integer>Gr[]; static long Mod=998244353; static Map<Integer,Integer>map=new HashMap<>(); public static void main(String [] args) { //...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 power(long long x, long long y, long long p) { long long res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p; } return res; } long double l, h, t; long double fu(long long a) { long double x1 = 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...
t = int(input()) for i in range(0, t): s = input().split() h = int(s[0]) c = int(s[1]) t = int(s[2]) if h+c == t*2: print(2) else: x = (t-h)/(h+c-t*2) l = int(x) r = l + 1 #print(2*l+1, "ansL") #print(2*r+1, "ansR") al = abs( ( (h*(l+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; void test_case() { double h, c, t; cin >> h >> c >> t; int cnt = 1; double dif = abs(h - t); if (abs((h + c) / 2 - t) < dif) { cnt = 2; dif = abs((h + c) / 2 - t); } if (2 * t != h + c) { double eq = fabs((double)(c - t) / (h + c - (2 * t))); d...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
t = int(input()) ans=[0]*t for i in range(t): h,c,obj=map(int, input().split()) ave=(h+c)/2 if obj<=ave: ans[i]=2 else: x=obj-ave y=(h-c)/2 z=y//x if z%2==0: z-=1 #print(x,y,z,ave) temp0=abs(obj-ave-y/z) temp1=abs(obj-ave-y/(2+z)) #print(temp0,temp1,y/z) if temp0<...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 >= t * 2: print(2) elif h <= t: print(1) else: k = (h - t) // (t * 2 - h - c) x = k * k * 2 + k * 5 y = k * k * 2 + k * 3 if (x + 3 + x + 2) * h + (y + y + 1) * c > 2 * (4 * k * 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 #from functools import lru_cache #import heapq #from collections import defaultdict #from collections import Counter #from collections import deque #from sys import stdout #from sys import setrecursionlimit #setrecursionlimit(10**7) from sys import stdin input = stdin.readline INF = 10**9 + 7 MAX = 10**7 ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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; const double eps = 1e-8; double getT(long long k) { double x = 1.0; return x * ((h + c) * k - c) / (2 * k - 1); } int main() { int T; long long t; scanf("%d", &T); while (T--) { scanf("%lld%lld%lld", &h, &c, &t); if (t == h) { puts(...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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.*; public class EdC { public static void main(String[] args) throws Exception{ int num = 998244353; // TODO Auto-generated method stub BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System....
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
#include <bits/stdc++.h> using namespace std; long long mod = 1000000000 + 7; int main() { long long T; cin >> T; start: while (T--) { double a, b, c; cin >> b >> a >> c; if (b == a) { cout << 1 << endl; goto start; } if (a + b == 2 * c) { cout << 2 << endl; goto start;...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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()) if a==c: print(1) continue if(a+b)/2 == c: print(2) continue temp = -1 l = 2 r = c+1 x = 2 while(l<r): mid = (l+r)//2 # print(l,r,mid,(mid*a+(mid-1)*b)/(2*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 java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; /** * https://codeforces.com/problemset/problem/1359/C * 3 * 30 10 20 * 41 15 30 * 18 13 18 should output 2, 7, and 1, each on a newline */ public final class Wa...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
tests=int(input()) for _ in range(tests): h,c,t=map(int,input().split()); if(t==h): print(1) continue if(t<=(h+c)/2): print(2) continue target=t-(h+c)/2 dif=h-c tmp=int(dif//(2*target)); if(tmp<=0): tmp=1; if(tmp%2==0): tmp=tmp-1 v...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 li = long int; using lli = long long int; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int _; cin >> _; while (_--) { double h, c, t; cin >> h >> c >> t; if (t <= (h + c) / 2) { cout << 2 << "\n"; continue; } ...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the hot water and pour it into an infinitely deep barrel; 2. take one cup of the cold water and pour it into an infin...
import java.io.*; import java.util.*; public class C{ public static Reader sc = new Reader(); //public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static long t,h,c; public static void main(String[] args) throws IOException { //BufferedReader br = new BufferedReader(new Fi...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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 -------------------- import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode...
There are two infinite sources of water: * hot water of temperature h; * cold water of temperature c (c < h). You perform the following procedure of alternating moves: 1. take one cup of the 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.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static...