Submit solution
Points:
30 (partial)
Time limit:
1.0s
Memory limit:
16M
Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python
FIB6
The Fibonacci sequence is defined by the following recursive formula:
The first terms of the sequence are: , , , , , , , , , , , , , , , , , and so on.
You are given a positive integer . You need to determine if can be expressed as the sum of at most six Fibonacci numbers, not necessarily distinct. If there are multiple ways to achieve this, you should find a solution with the smallest possible number of addends.
Input
The input consists of a single line containing a single integer .
Output
The output should consist of a single line containing:
- Either the word "", without the quotes, if cannot be written as the sum of at most six Fibonacci numbers,
- Or an integer between and , inclusive, followed by Fibonacci numbers separated by a single space, such that their sum is equal to and is minimized. If there are multiple correct solutions with the minimum number of addends, you can output any of them. All numbers in the line should be separated in pairs by a single space.
Constraints
.
Execution time limit: 1 sec.
Memory limit: 16 MB.
Examples of Input - Output
1st
STDIN (fib6.in)
42
STDOUT (fib6.out)
2 8 34
2nd
STDIN (fib6.in)
166418946
STDOUT (fib6.out)
3 6765 832040 165580141
3d
STDIN (fib6.in)
649814661
STDOUT (fib6.out)
impossible
Comments