CF593C.Beautiful Function
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Every day Ruslan tried to count sheep to fall asleep, but this didn't help. Now he has found a more interesting thing to do. First, he thinks of some set of circles on a plane, and then tries to choose a beautiful set of points, such that there is at least one point from the set inside or on the border of each of the imagined circles.
Yesterday Ruslan tried to solve this problem for the case when the set of points is considered beautiful if it is given as (x__t = f(t), y__t = g(t)), where argument t takes all integer values from 0 to 50. Moreover, f(t) and g(t) should be correct functions.
Assume that w(t) and h(t) are some correct functions, and c is an integer ranging from 0 to 50. The function s(t) is correct if it's obtained by one of the following rules:
- s(t) = abs(w(t)), where abs(x) means taking the absolute value of a number x, i.e. |x|;
- s(t) = (w(t) + h(t));
- s(t) = (w(t) - h(t));
- s(t) = (w(t) * h(t)), where * means multiplication, i.e. (w(t)·h(t));
- s(t) = c;
- s(t) = t;
Yesterday Ruslan thought on and on, but he could not cope with the task. Now he asks you to write a program that computes the appropriate f(t) and g(t) for any set of at most 50 circles.
In each of the functions f(t) and g(t) you are allowed to use no more than 50 multiplications. The length of any function should not exceed 100·n characters. The function should not contain spaces.
Ruslan can't keep big numbers in his memory, so you should choose f(t) and g(t), such that for all integer t from 0 to 50 value of f(t) and g(t) and all the intermediate calculations won't exceed 109 by their absolute value.
每天,鲁斯兰都会数羊来帮助自己入睡,但这并没有效果。现在他找到了一件更有趣的事情来做:首先,他在平面上构想出一些圆;然后,尝试选出一个“优美的”点集,使得每个构想出的圆内部或边界上都至少包含该点集中的一点。
昨天,鲁斯兰尝试解决这样一个特例问题:当点集被视为“优美”的,当且仅当它可表示为 (xt=f(t), yt=g(t)),其中参数 t 取遍从 0 到 50 的所有整数值;并且 f(t) 与 g(t) 必须是“合法函数”。
假设 w(t) 和 h(t) 是某些合法函数,c 是一个介于 0 到 50(含端点)之间的整数。函数 s(t) 被称为合法函数,当且仅当它由以下任一规则生成:
- s(t)=abs(w(t)),其中 abs(x) 表示对实数 x 取绝对值,即 ∣x∣;
- s(t)=(w(t)+h(t));
- s(t)=(w(t)−h(t));
- s(t) = (w(t) \* h(t)),其中 \* 表示乘法运算,即 (w(t)⋅h(t));
- s(t)=c;
- s(t)=t。
昨天鲁斯兰反复思考,却始终未能解决这一问题。现在他请你编写一个程序,对任意至多包含 50 个圆的集合,计算出相应的 f(t) 和 g(t)。
在函数 f(t) 和 g(t) 中,各自最多允许使用 50 次乘法运算。任一函数的长度不得超过 100⋅n 个字符(n 为圆的数量),且函数中不得包含空格。
鲁斯兰无法在记忆中存储很大的数,因此你所选定的 f(t) 和 g(t) 必须满足:对所有整数 t∈[0,50],f(t)、g(t) 以及所有中间计算结果的绝对值均不超过 109。
输入格式
The first line of the input contains number n (1 ≤ n ≤ 50) — the number of circles Ruslan thinks of. Next follow n lines, each of them containing three integers x__i, y__i and r__i (0 ≤ x__i, y__i ≤ 50, 2 ≤ r__i ≤ 50) — the coordinates of the center and the raduis of the i-th circle.
输入的第一行包含一个整数 n(1≤n≤50)—— 表示鲁斯兰所想的圆的数量。接下来有 n 行,每行包含三个整数 xi、yi 和 ri(0≤xi,yi≤50,2≤ri≤50),分别表示第 i 个圆的圆心坐标和半径。
输出格式
In the first line print a correct function f(t). In the second line print a correct function g(t). The set of the points (x__t = f(t), y__t = g(t)) (0 ≤ t ≤ 50) must satisfy the condition, that there is at least one point inside or on the border of each of the circles, Ruslan thinks of at the beginning.
第一行输出一个正确的函数 f(t)。第二行输出一个正确的函数 g(t)。点集 (xt=f(t), yt=g(t))(其中 0≤t≤50)必须满足如下条件:对于 Ruslan 最初所考虑的每一个圆,该点集中至少存在一个点位于该圆的内部或边界上。
输入输出样例
输入#1
3 0 10 4 10 0 4 20 10 4
输出#1
t abs((t-10))
说明/提示
Correct functions:
- 10
- (1+2)
- ((t-3)+(t*4))
- abs((t-10))
- (abs((((23-t)*(t*t))+((45+12)*(t*t))))*((5*t)+((12*t)-13)))
- abs((t-(abs((t*31))+14))))
Incorrect functions:
- 3+5+7 (not enough brackets, it should be ((3+5)+7) or (3+(5+7)))
- abs(t-3) (not enough brackets, it should be abs((t-3))
- 2+(2-3 (one bracket too many)
- 1(t+5) (no arithmetic operation between 1 and the bracket)
- 5000*5000 (the number exceeds the maximum)
The picture shows one of the possible solutions
正确的函数:
- 10
- (1+2)
- ((t-3)+(t*4))
- abs((t-10))
- (abs((((23-t)*(t*t))+((45+12)*(t*t))))*((5*t)+((12*t)-13)))
- abs((t-(abs((t*31))+14))))
错误的函数:
- 3+5+7(括号不足,应为 ((3+5)+7) 或 (3+(5+7)))
- abs(t-3)(括号不足,应为 abs((t-3)))
- 2+(2-3(左括号过多)
- 1(t+5)(数字 1 与括号之间缺少算术运算符)
- 5000*5000(数值超出上限)
图中展示了一种可能的解法
输入解题思路,AI测评打分。不知道怎么写?