From c0e0f5072822eb6372a1bd296a554482af97f77b Mon Sep 17 00:00:00 2001 From: Aditya Naik Date: Thu, 18 Jun 2020 23:39:46 -0400 Subject: necklace, coins and new problems in log --- 10054/necklace.bin | Bin 19600 -> 19560 bytes 10054/necklace.c | 11 +-- 11264/coin.c | 34 +++++++++ 11264/in | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++ log.org | 9 ++- 5 files changed, 249 insertions(+), 6 deletions(-) create mode 100644 11264/coin.c create mode 100644 11264/in diff --git a/10054/necklace.bin b/10054/necklace.bin index ff9a051..83a6db6 100755 Binary files a/10054/necklace.bin and b/10054/necklace.bin differ diff --git a/10054/necklace.c b/10054/necklace.c index f1d1e93..aa51236 100644 --- a/10054/necklace.c +++ b/10054/necklace.c @@ -12,7 +12,7 @@ bead *path; int adj[NUM_COLORS][NUM_COLORS] = {{0}}; int path_counter = 0; -int find_path(int x, int y, int curr) +void find_path(int x, int y, int curr) { bead new_bead = {x, y}; path[path_counter++] = new_bead; @@ -37,11 +37,12 @@ int find_path(int x, int y, int curr) } } } + if (found==0) - return 0; + return; curr = (curr+1)%2; find_path(new_x, new_y, curr); - return 1; + return; } int main() @@ -89,8 +90,8 @@ int main() } else { path_counter = 0; - int k=find_path(start_x, start_y, 0); - /* printf("find_path: %d\n", k); */ + find_path(start_y, start_x, 0); + printf("path counter: %d\n", path_counter); for (int x = 0; x < path_counter; x++) { if (x%2 != 0) printf("%d %d\n", path[x].c1+1, path[x].c2+1); diff --git a/11264/coin.c b/11264/coin.c new file mode 100644 index 0000000..2fa2dbb --- /dev/null +++ b/11264/coin.c @@ -0,0 +1,34 @@ +#include +#include + +int greedy(int c[], int size) +{ + int k = 0, curr_sum = c[0]; + int types = 2, x; + for (x=1; x < size-1; x++) { + if (c[x] + curr_sum < c[x+1]) { + curr_sum += c[x]; + types++; + } + } + return types; +} + +int main() +{ + int tc; + scanf("%d", &tc); + + while (tc--) { + int n, c[1000], x; + scanf("%d", &n); + for (x=0; x