Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.util.*;
import java.io.*;
public class Main {
static final int M = 1000000007;
static FastReader in = new FastReader();
// static PrintWriter out = new PrintWriter(System.out);
// static Scanner in = new Scanner(System.in);
// File file = new File("input.txt");
// Scanner in = new Scanner(file);
// Prin... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from collections import deque
import sys
def input(): return sys.stdin.readline().rstrip()
for _ in range(int(input())):
h, c, t = list(map(int, input().split()))
if (2 * t == c + h):
print(2)
continue
base = abs(h - c) // abs(2*t - c - h)
ans = 0
d = 2e18
for i in range(bas... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from math import floor, ceil
from fractions import Fraction as F
T = int(input())
for _ in range(T):
H, C, O = map(int, input().split())
if H == C or O >= H:
print(1)
elif O <= (H+C)/2:
print(2)
else:
x = F((O-C),(H-C))
N = F((x-1),(1-2*x))
low = floor(N)
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long INF = 1e17 + 7;
const long long mod = 1e9 + 7;
int main() {
long long t;
cin >> t;
while (t--) {
double h, c, t;
cin >> h >> c >> t;
double k = (h + c) / 2;
if (t <= k) {
cout << 2 << "\n";
} else ... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
double h, c, t;
inline double avg(long long m) { return (m * h + (m - 1) * c) / (2 * m - 1); }
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long tc;
cin >> tc;
while (tc--) {
cin >> h >> c >> t;
if (t == h) {
cout << "1\n... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
bool comp(const pair<int, int> &a, const pair<int, int> &b) {
if (a.first == b.first) return a.second < b.second;
return a.first < b.first;
}
bool comps(const pair<int, int> &a, const pair<int, int> &b) {
if (a.second == b.second) return a.first < b.first;
return a.... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.*;
import java.util.*;
public class Main
{
public static void main(String[] args) throws Exception
{
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out) ;
int T = sc.nextInt() ;
while (T-->0)
{
long h = sc.nex... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import os
import sys
if os.path.exists('/mnt/c/Users/Square/square/codeforces'):
_f = iter(open('C.txt').readlines())
def input():
return next(_f)
# input = lambda: sys.stdin.readline().strip()
else:
input = lambda: sys.stdin.readline().strip()
fprint = lambda *args: print(*args, flush=True)
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from fractions import Fraction as frac
import sys, os
input = sys.stdin.buffer.read().split(b'\n')[::-1].pop
from heapq import heappush, heappop
def i(): return input()
def ii(): return int(input())
def iis(): return map(int, input().split())
def liis(): return list(map(int, input().split()))
def pint(x): os.wri... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | for _ in range(int(input())):
h, c, t = map(int, input().split())
n = 0
ct = 0
if h == t: print(1)
elif t <= (h+c)//2: print(2)
else:
t -= (h+c)/2
t1 = ((h-c)/2)/t
x1 = int(((t1-1)//2)*2+1)
x2 = int(((t1+1)//2)*2+1)
if (h-c)/(x1*2)-t <= t - (h-c)/(x2*2): ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | # Template 1.0
from decimal import *
import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, floor
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitS... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from sys import stdin, exit
import fractions
input = stdin.readline
def i(): return input()
def ii(): return int(input())
def iis(): return map(int, input().split())
def liis(): return list(map(int, input().split()))
def print_array(a): print(" ".join(map(str, a)))
def eq(x):
return F((h*x + c*(x-1)),(x+x-1))
def ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | for _ in range(int(input())):
h,c,t = map(int,input().split())
if(h==t):print(1)
else:
if(((h+c)/2) >= t):print(2)
else:
dif=(t-((h+c)/2));j=int(abs((c-h)//(2*dif)))
if(j%2==0):j+=1
print(j-2) if(dif-(h-c)/(2*j)>=abs(dif-(h-c)/(2*(j-2)))) else print(j) ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
from fractions import Fraction as f
t = int(input())
for _ in range(t):
h, c, t = [int(x) for x in input().split()]
if h == t:
print(1)
continue
x = (h + c) / 2
if x == t:
print(2)
continue
y = (t - h) / ((h + c) - 2 * t)
if y < 0:
print(2)
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.util.Scanner;
public class MixingWater
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(int i=0; i<n; i++)
{
int hot=sc.nextInt();
int cold=sc.nextInt();
int goal=sc.nextInt();
if(goal<=(hot+cold)/2)
{
System.out.println(... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import math
t = int(input())
for i in range(0, t):
h, c, d = map(int, input().split(' '))
if d <= (h + c) / 2:
print(2)
else:
ex = (h-d) // (2*d-h-c)
if abs((ex * (h+c) + h) - d * (2*ex+1)) * (2*ex+3) <= abs((ex+1) * (h+c) + h - d * (2*ex+3)) * (2*ex+1):
print(2*ex+1)
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.ConnectException;
import java.rmi.dgc.Lease;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.u... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.util.*;
import java.io.*;
public class C {
public static void main(String[] args) throws IOException{
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
int t = Integer.parseInt(f.readLi... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
void solve() {
int h, c, t;
cin >> h >> c >> t;
if ((h + c) / 2 >= t) {
cout << 2 << '\n';
return;
}
int a = h - t;
int b = 2 * t - h - c;
int k = 2 * (a / b) + 1;
long long val1 = abs(k / 2 * 1ll * c + (k + 1) / 2 * 1ll * h - t * 1ll * k);
long lo... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
const int N = 1000;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int numCases = 1;
cin >> numCases;
for (int caseNo = 1; caseNo <= numCases; caseNo++) {
long long h, c, t;
cin >> h >> c >> t;
... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | # cook your dish here
import math
def bs(H, C, res):
lo = 0
hi = 10**12
ans = 0
while(lo<=hi):
mid = (lo + hi)//2
if (H*(mid+1) + ((mid)*C)) >= res*((2*mid) + 1):
lo = mid + 1
ans = mid
else:
hi = mid - 1
return ans
def main():
for q... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import bisect
import heapq
import math
import collections
import sys
import copy
from functools import reduce
import decimal
from io import BytesIO, IOBase
import os
import itertools
sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP
graphDict = collections.defaultdict
queue = colle... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual soluti... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
double h, c, t;
double f(ll i) { return (ll((i + 1) / 2) * h + ll(i / 2) * c) / (double)i; }
void solve() {
cin >> h >> c >> t;
if (t >= h) {
cout << 1 << endl;
return;
}
if (t <= (h + c) / 2) {
cout << 2 << endl;
return;
}
... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | for case in range(int(input())):
a = input().split(' ')
h = int(a[0])
c = int(a[1])
t = int(a[2])
avg = (h + c) / 2
if t < avg :
ans = 2
elif t == avg:
ans = 2
elif t == h:
ans = 1
elif h > t > avg:
diff = t - avg
v = (h-avg) // diff
if... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
import decimal as dc
dc.getcontext().prec = 18
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')
d... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
void solve() {
double a, b, c;
cin >> a >> b >> c;
double x = (a + b) - c - c;
double y = -c + b;
x = abs(x);
y = abs(y);
double hihi = abs(c - ((a + b) / 2.0));
double haha =
abs(c - (max(ceil(y / x), 1.0) * a + (max(ceil(y / x), 1.0) - 1) * b) /
... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from fractions import Fraction
T = int(input())
def TMP(h, c, nbH):
return c + Fraction(nbH, 2*nbH-1) * (h-c)
for _ in range(T):
h, c, t = [int(_) for _ in input().split()]
if t <= (h+c)//2:
print(2)
continue
L, R = 1, 10**9
a = 0
while L <= R:
m = (L+R)//2
t... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int inf = 0x7FFFFFFF;
const long long mod = (0 ? 1000000007 : 998244353);
const double eps = 1e-7;
const long long llinf = 4223372036854775807;
inline void out(long long a) {
if (a)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
void work() {
double... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
void solve() {
float h, c, t;
cin >> h >> c >> t;
if (t >= h) {
cout << "1\n";
return;
} else if (2 * t <= (h + c)) {
cout << "2\n";
return;
} else {
int val = (h - t) / (2 * t - h - c);
float t1 = ((val + 1) * h + val * c) / (2 * val + 1);... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
// BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int T=1;
T=sc.nextInt();
// int t=Inte... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.BufferedReader;
import java.io.InputStream;
/**
* Built using CHe... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | t = int(input())
for i in range(t):
h,c,t = map(int,input().split())
x = t - (h+c)/2
if x <= 0:
print(2)
else:
n = (h-c)//(2*t - h - c)
if n%2 == 0:
if abs(x - (h-c)/(2*(n+1))) > abs(x - (h-c)/(2*(n+3))):
print(n+3)
else:
pr... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long tst, h, c, t;
cin >> tst;
while (tst--) {
cin >> h >> c >> t;
if (t <= (h + c) / 2)
cout << 2 << '\n';
else {
long long t1 = (long long)ceil((h - t) / ((2 *... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int h, c, t;
cin >> h >> c >> t;
long long res1 = 0, res2 = 0;
if (h + c - 2 * t >= 0)
cout << 2 << endl;
else {
int a = h - t;
int b = 2 * t - c - h;
int k = 2 * (a / b) + 1;
... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 |
import java.util.*;
import java.lang.*;
import java.io.*;
import java.awt.Point;
// U KNOW THAT IF THIS DAY WILL BE URS THEN NO ONE CAN DEFEAT U HERE................
// ASCII = 48 + i ;// 2^28 = 268,435,456 > 2* 10^8 // log 10 base 2 = 3.3219
// odd:: (x^2+1)/2 , (x^2-1)/2 ; x>=3// even:: (x^2/4)+1 ,(x^2/4)-1 x >=... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 |
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int test = sc.nextInt();
while(test-->0)
{
long h = sc.nextLong();
long c = sc.nextLong();
long t = sc... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from decimal import *
T = int(input())
def ctemp(x):
return (h*(x+1)+c*x)/(2*x+1)
def ctemp2(x):
return (h*(x+1)+c*x)/(2*x+1)
for _ in range(T):
h,c,t = map(int,input().split())
now = abs((h+c)/2-t)
if (h+c)/2 >= t:
print(2)
else:
l = 0
r = h
while r > l + 1:
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from sys import stdin, gettrace
from fractions import Fraction
if not gettrace():
def input():
return next(stdin)[:-1]
# def input():
# return stdin.buffer.readline()
def main():
def solve():
h,c,t = map(int, input().split())
if t <= (h+c)/2:
print(2)
retu... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
double h, c, x;
cin >> h >> c >> x;
double lw = (h + c) / 2.0;
if (x <= lw) {
cout << 2 << '\n';
continue;
}
int l = -1, r = h;
int mn = 0;
... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
public class C { // change to name
String nameIn = getClass().getSimpleName() + ".i... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
input = sys.stdin.buffer.readline
def print(val):
sys.stdout.write(str(val) + '\n')
for _ in range(int(input())):
h, c, t = map(int, input().split())
if h <= t:
print(1)
elif (h + c) // 2 >= t:
print(2)
else:
n_c = (h - t) // (2 * t - h - c)
n_h = n_c ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
if sys.subversion[0] == "PyPy":
import io, atexit
sys.stdout = io.BytesIO()
atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
sys.stdin = io.BytesIO(sys.stdin.read())
input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RI = lambda x=int: map(x,RS().split... | PYTHON |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #!/usr/bin/env python
from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
from fractions import Fraction
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def oddVal(i, h, c):
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import bisect
import decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
fro... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | # |
# _` | __ \ _` | __| _ \ __ \ _` | _` |
# ( | | | ( | ( ( | | | ( | ( |
# \__,_| _| _| \__,_| \___| \___/ _| _| \__,_| \__,_|
import sys
import math
import operator as op
from functools import reduce
from sys import maxsize ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.*;
import java.util.*;
public class Codeforces
{
public static void main(String args[])throws Exception
{
BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb=new StringBuilder();
int t=Integer.parseInt(bu.readLine());
while(t--... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.util.*;
import java.io.*;
public class poker{
public static void main(String []args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int trials = Integer.parseInt(br.readLine());
for(int trial = 0; trial < trials; trial++){
... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | try:
for _ in range(int(input())):
h,c,t=map(int,input().split())
if h<=t:
print(1)
elif h+c>=2*t:
print(2)
else:
x=int((c-t)/(h+c-2*t))
m=abs((x*(h+c-2*t)+t-c)/(2*x-1))
n=abs(((x+1)*(h+c-2*t)+t-c)/(2*(x+1)-1))
i... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int q;
cin >> q;
while (q--) {
double t, h, c;
cin >> h >> c >> t;
if (h == t) {
cout << 1 << '\n';
} else if (h + c == 2 * t) {
cout << 2 << '\n';
} else {
... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.util.Scanner;
public class MixingWater
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(int i=0; i<n; i++)
{
int hot=sc.nextInt();
int cold=sc.nextInt();
int goal=sc.nextInt();
if(goal<=(hot+cold)/2)
{
System.out.println(... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | def read_int():
return int(input())
def read_ints():
return map(int, input().split(' '))
tt = read_int()
for case_num in range(tt):
h, c, t = read_ints()
if 2 * t <= h + c:
print(2)
continue
l = 1
r = int(1e7)
def calc(x): return x * h + (x - 1) * c
while l <= r:
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | //package cc;
import java.util.*;
public class Test {
static int caly(int h,int c,int t)
{
int ret;
ret=(h-t)/(2*t-h-c);
return ret;
}
public static void main(String [] arsg)
{
Scanner s=new Scanner(System.in);
int t=s.nextInt();
//Random r=new Random();
while(t-->0)
{
int h=s.nextInt();
int c=s.nextInt();
int te... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long int x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) {... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int n, long long int m) {
long long int res = 1;
while (n > 0) {
if (n & 1) res = (res * x) % m;
x = (x * x) % m;
n = n >> 1;
}
return res;
}
long long int maxSubsetSum(vector<long long int> v) {
long long... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
from collections import defaultdict
from copy import copy
from fractions import Fraction as FR
R = lambda t = int: t(input())
RL = lambda t = int: [t(x) for x in input().split()]
RLL = lambda n, t = int: [RL(t) for _ in range(n)]
def solve():
h, c, t = RL()
P = [(FR(abs(h - t)), 1), (abs(FR((h + ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from decimal import *
cases = int(input())
def get_delta(h, t, x):
return h * (1 + x) / (1 + 2*x) - t
for _ in range(cases):
h, c, t = [int(x) for x in input().split()]
if t <= (h + c) / 2:
print(2)
continue
# h = Decimal(h - c)
# t = Decimal(t - c)
h = h - c
t = t - c
x = 0
delta = get_delta(h, t, x)
w... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
input = sys.stdin.readline
"""
infinite water:
h = hot water
c = cold water (c < h)
"""
from decimal import Decimal
from math import floor, ceil
def calc_temp(cups, h, c):
# cups = total cups
if cups <= 0:
return 0
if cups % 2 == 0:
return ((h * (cups/2) + c * (cups/2))) ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from collections import Counter
import math
import sys
from bisect import bisect,bisect_left,bisect_right
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def mod()... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
} ... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from sys import stdin, stdout
# 30, 10, 20
# (30x + 10y) / (x + y) = 20
# x = y || x = y+1
# 40x / 2x = 20
# (30x + 10x - 10) / (2x - 1) = 20
# (10x + 30x - 30) / (2x - 1) = 20
# (40x - 10) / (2x - 1)
# 40x/(2x-1) - 10/(2x-1)
# 40x/(2x-1) - 30/(2x-1)
# (30x + 10(x - 1)) / (2x - 1)
def mixing_water(h, c, t):
r... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.*;
import java.util.*;
public class Solution {
public static void main(String args[]) throws IOException {
InOut inout = new InOut();
Resolver resolver = new Resolver(inout);
resolver.solve();
inout.flush();
}
private static class Resolver {
final l... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
long long tt;
cin >> tt;
label:
while (tt--) {
long long h, c, t;
cin >> h >> c >> t;
if (h == t) {
cout << 1 << "\n";
goto label;
}
long long x;
long double answer;
long long ans;
if (double(h - t) <= abs((h + ... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Scanner;
public class Problem1359C {
private static long solveSingle(int h, int c, int t) {
if (t <= (h + c) / 2)
return 2;
long hotN = (t - c) / (2 * t ... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | def solve():
h, c, t = [int(x) for x in input().split()]
if h == c:
print(1)
elif t >= h:
print(1)
elif 2 * t <= h + c:
print(2)
else:
ans = (h - c) // (2 * t - h - c)
if ans % 2 == 0:
ans += 1
variants = []
variants.append(ans)
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 |
import java.io.*;
import java.util.*;
public class Test {
public static void main(String[] args) {
FastScanner in = new FastScanner();
// Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int T = in.nextInt();
int h, c, t, x, y, minx;
... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 |
import java.io.*;
import java.util.*;
public class Main {
private static final boolean N_CASE = true;
private void solve() {
int h = sc.nextInt();
int c = sc.nextInt();
int t = sc.nextInt();
long left = 0, right = Integer.MAX_VALUE;
while (left <= right) {
... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | t = int(input())
for _ in range(t):
h, c, g = [int(x) for x in input().split()]
av = (h + c)/2
if g == h:
print(1)
elif g <= av + 0.001:
print(2)
else:
# after 2n+1 pours (n = 0, 1, ...) we have a temp of ((n+1)*h + n*c)/(2*n+1) = g,
# so we have n*(h+c) + h = g*(2*n... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | for i in range(int(input())):
h, c, t= map(int, input().split())
result = float('inf')
avg = (h+c)/2
D = {}
if(t==h):
result = 1
elif(t in (c,avg)):
result = 2
else:
D[abs(t-c)] = 2
D[abs(t-h)] = 1
if(t-avg > 0):
X = (h-avg)/(t-avg)
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long N = 200005;
bool col2(pair<long long, long long> p1, pair<long long, long long> p2) {
if (p1.second == p2.second) return p1.first > p2.first;
return p1.second > p2.second;
}
struct comp {
bool operator()(long long const &x, long long const &y) { return... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import math
from decimal import *
T= int(input())
def f(j):
a=Decimal((h+c)*(j//2) + h*(j%2))/Decimal(j)
return abs(a-t)
for i in range(T):
h,c,t= map(int,input().split())
if h==t:
print(1)
elif (h+c)//2 == t:
print(2)
else:
k=(h-t)//(2*t-h-c)
z=(c-t)//(h+c-2*t)
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | T = int(input())
for _ in range(T):
h, c, t = map(int, input().split())
if h + c >= t * 2:
print(2)
else:
l, r = 0, 10 ** 9
while r - l > 1:
m = (l + r) // 2
if h * (m + 1) + c * m >= t * (2 * m + 1):
l = m
else:
r =... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 |
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Sola3 {
public int minCups(int h, int c, int t){
// 12/4
if(((h+c)%2) == 0 && (h+c)/2 == t)return 2;
if(h == t)return 1;
int x = c - t;
int y = h+c - 2*t;
if(x < 0 && y <0){
x = x * -1;
y = y*-1;
}
if(x == 0|| (x < 0... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
input = sys.stdin.buffer.readline
def print(val):
sys.stdout.write(str(val) + '\n')
def val(x,h,c):
return (h-c)/(2*(x*2 -1))
def prog():
for _ in range(int(input())):
L = 1
R = 10**6
h,c,t = map(int,input().split())
if t <= (h+c)/2:
print(2)
el... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Path;
import java.util.*;
public class Solution {
static class Pair{
String s;
int pos;
Pair(String s, int pos){
this.s = s;
this.pos = pos;
}
... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.util.*;
import java.io.*;
public class _1359_C {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int t = Integer.parseInt(in.readLine());
for(int i = 0; i < t; i++)... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import 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
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | T = int(input())
for _ in range(T):
h,c,t = map(int,input().split())
if h+c >= 2*t:
print(2)
else:
x = (h-t)//(2*t-c-h)
y = x+1
if abs(h*(x+1)+c*x-t*(2*x+1))*(2*y+1) <= abs(h*(y+1)+c*y-t*(2*y+1))*(2*x+1):
print(2*x+1)
else:
print(2*y+1)
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long int INF = (long long int)1e18;
const long long int MOD = (long long int)1e9 + 7;
const long long int maxn = (long long int)2e5 + 10, L = 23;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int T;
cin >> T;
while (T--) {
... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #-------------------- 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... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
__author__ = 'ratmir'
from collections import deque
from math import asin, pi, tan
alphabet = "abcdefghijklmnopqrstuvwxyz"
def solve(n, a, graph):
return 1
def execute():
[t] = [int(x) for x in sys.stdin.readline().split()]
results = []
for ti in range(0, t):
[h, c, t] = [int(x... | PYTHON |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.*;
import java.util.*;
public class Contest1 {
static int[][][]memo;
static int[]a;
static int dp(int state,int mx,int idx){
if (idx==a.length)
return state==0?0:-(mx-30);
if (memo[state][mx][idx]!=-1)
return memo[state][mx][idx];
int ans=0;... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;
public class Main {
//static final long MOD = 998244353L;
//static final long INF = 1000000000000000007L;
static String letters = "abcdefghijklmnopqrstuvwxyz";
static final long MOD = 1000000007L;
static final int INF = 1000000007;
... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int q;
cin >> q;
while (q--) {
double h, c, t;
cin >> h >> c >> t;
long long ans = 0;
long long l = 0;
long long r = 1000000;
long long diff = 10000000000;
double cnt = 100000000.100;
while (l <= r) {
long long mid = ... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from sys import stdin
input = stdin.readline
for _ in range(int(input())):
h, c, t = map(int, input().split())
if t >= h:
print(1)
continue
if 2 * t <= h + c:
print(2)
continue
l, r = 1, 1000000000
while l < r:
m = (l + r) >> 1
if m * h + (m - 1) * c > (2 * m - 1) * t:
l = m + 1
else:
r = m
k ... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from fractions import Fraction as frac
t = int(input())
for _ in range(t):
hotTemp, coldTemp, barrelTemp = map(int, input().rstrip().split())
if barrelTemp == hotTemp:
print(1)
elif (hotTemp+coldTemp) >= barrelTemp*2:
print(2)
else:
cups1 = (barrelTemp - coldTemp) // ((2 * barrel... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | #include <bits/stdc++.h>
long long int mod = 1e9 + 7;
using namespace std;
const long long int INF = 1e18;
const long long int MAX = 2e5 + 10;
long long int power(long long int a, long long int b) {
if (b == 0) return 1;
long long int num = 1;
long long int m = mod + 2;
while (b != 1) {
if (b % 2 == 0) {
... | CPP |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | // Working program using Reader Class
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.*;
public class Main
{
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private ... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
for _ in range(int(input())):
h, c, t = map(int, input().split())
if h <= t:
print(1)
elif (h + c) // 2 >= t:
print(2)
else:
n_c = (h - t) // (2 * t - h - c)
n_h = n_c + 1
if abs((n_c * c +... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import math
def f(k,h,c,t):
return ((2*k)+3)*abs(k*(h+c)+h-(2*t*k)-t)<=((2*k)+1)*abs((k+1)*(h+c)+h-(2*t*k)-(3*t))
t=int(input())
for _ in range(t):
ar=input().split()
h=int(ar[0])
c=int(ar[1])
t=int(ar[2])
if t==h:
print(1)
else:
if 2*t<=h+c:
print(2)
else... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
import heapq
def gcd(a, b):
if a < b:
a, b = b, a
if b == 0:
return a
return gcd(b, a % b)
def main():
a = int(input())
for _ in range(a):
h, c, t = map(int, sys.stdin.readline().split())
if t >= h:
print(1)
continue
if t <... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys, fractions
range = xrange
inp = [int(x) for x in sys.stdin.read().split()]
ii = 0
def rint():
global ii
i = ii
ii += 1
return inp[i]
def rints(n):
global ii
i = ii
ii += n
return inp[i:ii]
def rintss(n, k):
global ii
i = ii
ii += n * k
return [inp[i + j: ii... | PYTHON |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuilder ans = new StringBuilder();
int tt = sc.nextInt();
while (tt-- > 0) {
int h = sc.nextInt();
int c = sc.nextInt();
... | JAVA |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import math
from decimal import Decimal
n = int(input())
for i in range(n):
h,c,t = map(int,input().split())
if t<=(h+c)/2:
print(2)
continue
avg = (h-t)/(2*t-h-c)
a = max(0,math.floor(avg)+1)
b = max(0,math.floor(avg))
t1 = Decimal((a+1)*h+a*c)/(2*a+1)
t2 = Decimal((b+1)*h+b... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | for _ in range(int(input())):
h,c,t = map(int,input().split())
if(h==t):
print(1)
else:
if(((h+c)/2) >= t):
print(2)
else:
dif=(t-((h+c)/2));j=int(abs((c-h)//(2*dif)))
if(j%2==0):
j+=1
if(dif-(h-c)/(2*j)>=abs(dif-(h-c)/(... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | import sys
input = sys.stdin.buffer.readline
import math
T = int(input())
for _ in range(T):
h, c, t = map(int, input().split())
if t <= (h+c)/2:
print(2)
else:
if (h-t)%(2*t-h-c)==0:
x = (h-t)//(2*t-h-c)
print(2*x+1)
else:
x = (h-t)/(2*t-h-c)
... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from sys import stdin
###############################################################
def iinput(): return int(stdin.readline())
def sinput(): return input()
def minput(): return map(int, stdin.readline().split())
def linput(): return list(map(int, stdin.readline().split()))
############################################... | PYTHON3 |
1359_C. Mixing Water | There are two infinite sources of water:
* hot water of temperature h;
* cold water of temperature c (c < h).
You perform the following procedure of alternating moves:
1. take one cup of the hot water and pour it into an infinitely deep barrel;
2. take one cup of the cold water and pour it into an infin... | 2 | 9 | from sys import stdin, stdout
from decimal import *
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 - Decimal(h... | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.