TopCoder

User's AC Ratio

100.0% (3/3)

Submission's AC Ratio

35.0% (7/20)

Tags

Description

剛學會陣列的小明想用程式來算費氏數列,但他卡住了,你可以幫幫他嗎?

現在給你一個正整數 $N$,請你照順序輸出費氏數列前 $N$ 項,並用空白分隔。費氏數列的定義如下(以下用 $fib_i$ 代表費氏數列第 $i$ 項):

$$
fib_i=
\begin{cases}
1 &, i = 1 \newline
1 &, i = 2 \newline
fib_{i-2} + fib_{i-1} &, \text{otherwise} \newline
\end{cases}
$$

Input Format

輸入只有一行,包含一個正整數 $N$,代表你要輸出費氏數列的前 $N$ 項。

  • $1\le N\le 45$

Output Format

請輸出一行由空格分開的整數,代表費氏數列的前 $N$ 項。

Sample Input 1

10

Sample Output 1

1 1 2 3 5 8 13 21 34 55

Sample Input 2

1

Sample Output 2

1

Hints

Problem Source

Subtasks

No. Testdata Range Constraints Score
1 0~1 範例測資 0
2 0~2 無額外限制 100

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 524288 65536 1 2
1 1000 524288 65536 1 2
2 1000 524288 65536 2