Skip to content

Commit

Permalink
Solve Iccanobif in python
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscostadsc committed Jul 23, 2024
1 parent b91739c commit a7770c5
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 0 deletions.
26 changes: 26 additions & 0 deletions solutions/beecrowd/2807/2807.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys

memoized_fibonacci = [0] * 41


def fibonacci(n):
global memoized_fibonacci

if memoized_fibonacci[n] != 0:
return memoized_fibonacci[n]

if n in (1, 2):
memoized_fibonacci[n] = 1
else:
memoized_fibonacci[n] = fibonacci(n - 1) + fibonacci(n - 2)

return memoized_fibonacci[n]


for line in sys.stdin:
for i in range(int(line), 0, -1):
print(str(fibonacci(i)), end='')
if i == 1:
print()
else:
print(' ', end='')
40 changes: 40 additions & 0 deletions solutions/beecrowd/2807/in.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
40 changes: 40 additions & 0 deletions solutions/beecrowd/2807/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
1
1 1
2 1 1
3 2 1 1
5 3 2 1 1
8 5 3 2 1 1
13 8 5 3 2 1 1
21 13 8 5 3 2 1 1
34 21 13 8 5 3 2 1 1
55 34 21 13 8 5 3 2 1 1
89 55 34 21 13 8 5 3 2 1 1
144 89 55 34 21 13 8 5 3 2 1 1
233 144 89 55 34 21 13 8 5 3 2 1 1
377 233 144 89 55 34 21 13 8 5 3 2 1 1
610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
14930352 9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
24157817 14930352 9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
39088169 24157817 14930352 9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
63245986 39088169 24157817 14930352 9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
102334155 63245986 39088169 24157817 14930352 9227465 5702887 3524578 2178309 1346269 832040 514229 317811 196418 121393 75025 46368 28657 17711 10946 6765 4181 2584 1597 987 610 377 233 144 89 55 34 21 13 8 5 3 2 1 1
25 changes: 25 additions & 0 deletions solutions/beecrowd/2807/problem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
https://judge.beecrowd.com/en/problems/view/2807

# Iccanobif

Iccanobif sequences are sequences where each term is always equal to the sum of
the next two subsequent to it. Except for the last two terms which are always
equal to 1

Example of an Iccanobif sequence with 10 terms: 55, 34, 21, 13, 8, 5, 3, 2, 1,
1.

Your task is, given an integer value, print the corresponding size Iccanobif
sequence.

## Input

The entry consists of a single integer $N (1 \leq N \leq 40)$ representing the
size of the desired Iccanobif sequence.

## Output

The output consists of a single line containing the terms of the Iccanobif
sequence of $N$ size separated by a single space.


1 change: 1 addition & 0 deletions solutions/beecrowd/2807/tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
beginner

0 comments on commit a7770c5

Please sign in to comment.