ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила

Novosibirsk SU contest. Petrozavodsk training camp. Summer 2007

Описание     Задачи     Отправить на проверку     Состояние проверки     Результаты
Соревнование завершено

G. Periodical Numbers

Ограничение времени: 1.0 секунды
Ограничение памяти: 64 МБ
Little Tom likes amusing mathematical tasks a lot. After studying ordinary periodical numbers he wondered, what if period will be before decimal point. Generally speaking, such a "number" will have infinite number of digits before decimal point, and it will not be even a number, but it is possible to apply some operations to them. But after trying to sum up this numbers for a while, he found this task a bit complicated, even when numbers have periods of the same length and don't have unperiodical part. So he decided to write a program that will solve this problem. But he is not very good at programming, so asked you to help him and write it.
Periodical numbers can be written in form (a1a2ak)b1b2bm = …a1a2ak a1a2ak a1a2ak b1b2bm, where ai and bj are digits. The summation process starts from the less significant digit and going on like in addition of normal numbers, but never finishes. Your task is to sum up two periodical infinite numbers.

Исходные данные

Input has two lines containing two infinite periodical numbers each. It is guaranteed that the given numbers will not have unperiodical part (i.e. will be given in form "(a1a2ak)") and the given periods of numbers will be the same length not greater than nine.

Результат

The output must have one line containing desired number itself. It must be printed in the representation with minimal period length. Among such representations the one having the least unperiodical part's length must be chosen.

Пример

исходные данныерезультат
(234)
(342)
(576)
Источник задачи: Novosibirsk SU Contest. Petrozavodsk training camp, September 2007
Чтобы отправить решение этой задачи на проверку перейдите в Архив задач: 1558. Periodical Numbers