-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8da1eb2
commit 8ee4319
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Exercise 10867 | ||
""" | ||
10 | ||
1 4 2 3 1 4 2 3 1 2 | ||
""" | ||
count = input() | ||
num_list = raw_input().split(' ') | ||
num_list = map(int, num_list) | ||
num_list = list(set(num_list)) | ||
num_list.sort() | ||
|
||
for i in num_list: | ||
print i, |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
static int *Fibonacci_array = 0; | ||
static int tmp_malloc_size = 0; | ||
|
||
int Fibonacci_function(int num) | ||
{ | ||
int num_tmp = num; | ||
int result =1; | ||
int cnt = 1; | ||
int tmp = 1; | ||
int i = 1; | ||
|
||
//Calc Fibornacci | ||
Fibonacci_array = (int*)malloc(sizeof(int)*num_tmp); | ||
|
||
Fibonacci_array[0] = 0; | ||
Fibonacci_array[1] = 1; | ||
|
||
if (num == 0){ | ||
tmp_malloc_size = 1; | ||
return 0; | ||
} | ||
|
||
else if (num == 1){ | ||
tmp_malloc_size = 2; | ||
return 0; | ||
} | ||
|
||
|
||
while (i < num){ | ||
// printf("%d ",result); | ||
Fibonacci_array[i] = result; | ||
i++; | ||
|
||
tmp = result; | ||
result += cnt; | ||
cnt = tmp; | ||
} | ||
|
||
//set malloc size | ||
tmp_malloc_size = i; | ||
return 0; | ||
} | ||
|
||
|
||
|
||
int main(int argc, char *argv[]){ | ||
|
||
int T; | ||
scanf("%d", &T); | ||
Fibonacci_function(T); | ||
|
||
Fibonacci_array[0] = 0; | ||
Fibonacci_array[1] = 1; | ||
printf("%d\n", Fibonacci_array[tmp_malloc_size-1]); | ||
|
||
|
||
// for (int j=0;j< tmp_malloc_size;j++){ | ||
// printf("%d,", Fibonacci_array[j]); | ||
// } | ||
|
||
//malloc free | ||
free(Fibonacci_array); | ||
return 0; | ||
} |