codeforces 593 C. Beautiful Function

C. Beautiful Function
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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(xt = f(t), yt = 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:

  1. s(t) = abs(w(t)), where abs(x) means taking the absolute value of a number x, i.e. |x|;
  2. s(t) = (w(t) + h(t));
  3. s(t) = (w(t) - h(t));
  4. s(t) = (w(t) * h(t)), where  *  means multiplication, i.e. (w(th(t));
  5. s(t) = c;
  6. 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) andg(t) and all the intermediate calculations won't exceed 109 by their absolute value.

Input

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 xiyi and ri (0 ≤ xi, yi ≤ 502 ≤ ri ≤ 50) — the coordinates of the center and the raduis of the i-th circle.

Output

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 (xt = f(t), yt = 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.

Sample test(s)
input
3
0 10 4
10 0 4
20 10 4
output
t 
abs((t-10))

(1 - abs(x - i) + abs(abs(x - i) - 1))是一个类似开关的函数,知道这个就好搞了
/*======================================================
# Author: whai
# Last modified: 2015-11-06 14:32
# Filename: c.cpp
======================================================*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define LL __int64
#define PB push_back
#define P pair<int, int>
#define X first
#define Y second
const int N = 55;
P a[N];

int main() {
    int n;
    scanf("%d", &n);
    int r;
    for(int i = 0; i < n; ++i) {
        scanf("%d%d%d", &a[i].X, &a[i].Y, &r);
    }
    string left = "(((1-abs((t-", mid = ")))+abs((abs((t-", right = "))-1)))";
    string ans1 = "";
    string ans2 = "";
    for(int i = 0; i < n - 1; ++i) {
        ans1 += "(";
        ans2 += "(";
    }   
    for(int i = 0; i < n; ++i) {
        string num = to_string(i);
        ans1 += left + num + mid + num + right + "*" + to_string(a[i].X / 2) + ")";
        ans2 += left + num + mid + num + right + "*" + to_string(a[i].Y / 2) + ")";
        if(i != 0) ans1 += ")", ans2 += ")";
        if(i != n - 1) ans1 += "+", ans2 += "+";
    }
    cout<<ans1<<endl;
    cout<<ans2<<endl;
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值