import typing
from typing import Callable
from typing import AnyStr
from typing import Any
from typing import Iterable
from typing import List
--- Python 3.8.3 ---
def ListTransform(Data: List[Any], Tranformer: Callable[[Any], bool], Selector: Callable[[Any], bool] = None):
temp = Data.copy()
if Selector != None:
for index, item in enumerate(Data):
if (Selector(item)):
temp[index] = Tranformer(item)
else:
for index, item in enumerate(Data):
temp[index] = Tranformer(item)
return temp
def main():
a, b = [float(input()) for _ in range(2)]
if (abs(a) > abs(b)):
a, b = ListTransform([a,b], lambda Item: Item / 2)
print(a,b)
Объяснение:
#include <iostream>
typedef long long ll;
using namespace std;
bool ll_is_valid(ll t, ll N, ll x, ll y)
{
return t / x + (t - x) / y >= N;
}
ll f(ll N, ll x, ll y)
{
ll R = 1;
while (!ll_is_valid(R,N,x,y)) R *= 2;
ll L = R / 2;
while(R - L > 1)
{
ll M = (L + R) / 2;
if (!ll_is_valid(M,N,x,y)) {L = M;}
else {R = M;}
}
return R;
}
int main()
{
ll N,x,y;
cin >> N >> x >> y;
if(x > y) swap( x, y );
cout << f(N, x, y) << std::endl;
}
python
a = int(input('Введите первое число: '))
b = int(input('Введите второе число: '))
if abs(a) > abs(b):
a /= 2
b /= 2
print(a)
print(b)