Имя: Пароль: Зарегистрироваться Восстановить пароль
28/01/2023 14:55:58

# Рабочее место участника

## Задачи

658. Fair Sharing

Ограничения: время – 1s/2s, память – 4MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод
Послать решение Blockly Посылки Темы Где Обсудить (0)

Gnomes snatched away the sweets from a vase, which Snow-white had place on the round table.
"Stop! You haven't left any sweets for me!" – Snow-white exclaimed. – "We need to share the sweets equally."
Snow-white counted the sweets; there were 15 sweets.
"Fifteen cannot be divided on eight. Let's do it like this. Put your sweets into bowls." – After it had been done, Snow-white continued. – "Let's enumerate bowls clockwise from 1 up to 8. My bowl will be under number 1. I will turn away and call the numbers from 1 to 8. Somebody takes all the sweets from the called bowl and distribute one in each bowl clockwise, starting from the next one after the called. I think, after several such operations the sweets will be distributed on cups in random."
The gnomes agreed, that this sharing would be fairer, as the results will depend on case, but not on "the length of raking arms" (Grumbler said so, who had got only one sweet). But as a result Grumbler got nothing, because Snow-white was offended with him for grumbling about the quality of yesterday's dinner. Snow-white differed from her stepmother not only in beauty, but also in wit (at least, it did not come into her mind to talk to a mirror), therefore Snow-white easily invented, how to achieve more fair distribution (from her point of view) from initial distribution of sweets among bowls.
Write the program, which determines according to initial and finite distribution of 15 sweets among 8 bowls a sequence of numbers, which needs to be pronounced by Snow-white.
Input
The first line of the input file contains 8 integers (in the range from 0 to 15 inclusively, the sum is 15), separated by spaces; this is initial distribution of sweets among bowls (clockwise, starting from a bowl #1). Second line contains 8 integers (in the range from 0 to 15 inclusively, the sum is 15), separated by spaces; this is required finite distribution of sweets among bowls (clockwise, starting from a bowl #1).
Output
On the first line of the output file write one integer N representing an amount of called numbers. The following N lines of the output file with numbers from 1 up to 8 representing a sequence of called numbers. Any variant, even not necessarily the shortest, may be pointed.

Sample of input

0 3 1 2 1 3 1 4
3 3 0 2 2 3 1 1


Output for the sample input

7
2
4
6
5
8
7
3