Дистанционный практикум по программированию

Задачи Online статус Турниры
Учебники Справка СДО
Здравствуйте, Гость! Войдите с паролем или зарегистрируйтесь.

1330. Sages

Ограничение времени: 1 сек.
Ограничение памяти:65536 КБайт
Статистика Послать на проверку Задачу добавил debug

A group of sages had a very lively discussion of sophisticated topics. After a while, feeling quite tired, they thought that some good tea and a big tasty apple pie would make them feel much better. However, the sages found it boring to cut the pie into equal pieces, so they took a more challenging path. The first sage takes 1/k1-th part of the whole pie, the second 1/k2-th, the third 1/k3-th and so on. Here, the numbers k1, k2, k3, … kn are different positive integers not exceeding 100 (even the wisest sage is unable to precisely cut off less than 1/100 of a pie).

Your task is to write a program that will split the pie in such a way that each sage gets 1/ki-th of the whole pie (the pie must be shared without remainder!), or report that it is impossible to split the pie under these conditions. In case of several possible solutions, any of them will be considered correct.


1 £ n £ 20;

k1, k2, …, kn are positive integer numbers, 1 £ ki £ 100;

1/k1 + 1/k2 + 1/k3 + … + 1/kn = 1;

ki kj, for any i, j, ij.


The input file contains a single integer n, the number of sages sharing the pie.


The output file should contain n space-delimited integers k1, k2, …, kn. If there is no solution then the output file should contain the message “No solution” (without quotation marks).





2 3 6


No solution




2 4 6 12


Статистика Послать на проверку Обсуждение задачи Автор/источник:
Задачи с соревнований / Чемпионат ACM / Рыбинск-2014 /
1329. E - 4x4 1330. 1331. G - Bus Conductor 1332. H - Cryptography 1333. I - Belt Drive
время генерации 0.141 сек.
© Copyright ВоГУ, АВТ, Носов Д.А., Андрианов И.А.