using
System;
using
System.Collections;
using
System.Collections.Generic;
class
GFG{
static
bool
splitIntoFibonacciHelper(
int
pos,
string
S,
ArrayList seq)
{
if
(pos == S.Length && (seq.Count >= 3))
{
return
true
;
}
long
num = 0;
for
(
int
i = pos; i < S.Length; i++)
{
num = num * 10 + (S[i] -
'0'
);
if
(num > Int64.MaxValue)
break
;
if
(S[pos] ==
'0'
&& i > pos)
break
;
if
(seq.Count> 2 &&
(num > ((
long
)seq[seq.Count - 1] +
(
long
)seq[seq.Count - 2])))
break
;
if
(seq.Count < 2 ||
(num == ((
long
)seq[seq.Count - 1] +
(
long
)seq[seq.Count - 2])))
{
seq.Add(num);
if
(splitIntoFibonacciHelper(i + 1,
S, seq))
return
true
;
seq.Remove(seq.Count - 1);
}
}
return
false
;
}
static
void
splitIntoFibonacci(
string
S)
{
ArrayList seq =
new
ArrayList();
splitIntoFibonacciHelper(0, S, seq);
if
(seq.Count >= 3)
{
for
(
int
i = 0; i < seq.Count; i++)
Console.Write(seq[i] +
" "
);
}
else
{
Console.Write(
"-1"
);
}
}
public
static
void
Main(
string
[] args)
{
string
S =
"11235813"
;
splitIntoFibonacci(S);
}
}