## Search found 56 matches

Thu Jun 19, 2008 10:44 am
Forum: Algorithms
Topic: Bar cutting problem
Replies: 0
Views: 1195

### Bar cutting problem

I have to write an algorithm to optimize cutting smaller bars from a minimum number of full length (uncut) bars. The full length of an entire (uncut) bar is 1200. Then I get a set of smaller bars in length&number pairs like 12bars of length 350, 6bars of length 400, etc. The problem is to find the b...
Fri Jun 24, 2005 10:04 am
Forum: Algorithms
Topic: algorithm/ideas needed
Replies: 4
Views: 1621
actually, a 6 side triangle can be broken into 9 2-side triangles that cover the exact same area. So, whatever u can cover with a 6 sider, u can also cover with 2 side triangle. /\ /\ / \ /\ /\ /____\ / \/ \/\ something like that, with 5,3 and 1 2 side triangles on the rows.
Thu Jun 23, 2005 2:54 pm
Forum: Algorithms
Topic: algorithm/ideas needed
Replies: 4
Views: 1621
sorry, ah = lh*lh*sqrt(3)*3/2
Thu Jun 23, 2005 2:50 pm
Forum: Algorithms
Topic: algorithm/ideas needed
Replies: 4
Views: 1621
i have no theorem to back me up, but here's a guess: if lh is the hexagon's side length, ah it's area, lt1..ltn the triangle sides and atn their areas, then if u can write lh as a sum of lt1..ltn and ah as a sum of at1..atn then i belive the hexagon can be splited. at = lt *lt *sqrt(3)/4; ah = lh*lh...
Thu Jun 23, 2005 1:42 pm
Forum: Algorithms
Topic: Usaco problem (contact) in section 2.1
Replies: 6
Views: 1750
hi. my idea is something like: generate all possible sequences in A-B bit range and convert to a string. use the strstr function to go through the message string and count occurences. of course, if a=1 and b=12 there are a lot of cases, but there is a catch: 00 will allways have less occurences than...
Mon Jun 06, 2005 12:34 pm
Forum: Volume 1 (100-199)
Topic: 119 - Greedy Gift Givers
Replies: 145
Views: 24831
i think ur problem is that when (mon_hav/num_rec) yields a remainder, u loose that money, which should be added to rec[nth_per].
in the first example, dave gives 200 to 3 people. that means 198 is given and 2 remains to him. after getting 300 from others, he has in the end 302.
Fri Jun 03, 2005 2:22 pm
Forum: Algorithms
Topic: Panel
Replies: 5
Views: 1247
hi. i assume BF comes from brute force. also i assume by BF in this case u mean the one presented on the page for the easy test-case. what is the monte-carlo solution? what euristic method have u used, the one they present? please clarify theese things to me. here's some math i did on this. is it ac...
Fri Jun 03, 2005 12:08 pm
Forum: C
Topic: quicksort built in
Replies: 8
Views: 8246
using a->key - b->key is dangerous because of overflow!
if u r not sure it will fit (in the example into int), u shuold use ifs with
<,> or typecast one of them to a larger type (in the example long will do).
Fri Jun 03, 2005 12:02 pm
Forum: C
Replies: 5
Views: 3665
actually, "%s" skips all preceeding blank spaces (specified in isspace() for instance), which are more then " ", "\n" and "\r". (the tab is a blank surely "\t"). as for reding from a string, here's a good topic, which gives u all the solutions u need: http://acm.uva.es/board/viewtopic.php?t=7539&sid...
Fri Jun 03, 2005 11:42 am
Forum: C
Topic: scanf in 10013!
Replies: 1
Views: 2179
more generally, if u need to skip any number of blank spaces (which are specified by isspace() for instance), u can also use scanf(" ");
the "%s", "%d", "%f" type conversion specifiers do this implicitly.
Fri Jun 03, 2005 11:27 am
Forum: C
Topic: Things that produce compile error
Replies: 3
Views: 3505
well, u use double type as index for an array.
that's a no-no. if u're sure the values are integer, u can cast, but carefull for overflow & precision.
Fri Jun 03, 2005 11:24 am
Forum: C
Topic: Weird Invalid Memory Reference?
Replies: 5
Views: 3070
also interested. can u post the code?
an idea: maybe u forgot the & in scanf...
Fri Jun 03, 2005 10:33 am
Forum: C
Topic: malloc
Replies: 17
Views: 8318
a very interesting thing i've never seen b4 was the int **a = (int **)calloc(10*10,sizeof(int)); a[0][2]=3 yes, triky way to get rid of some sintax, but let's see what happens, actually. The "sintactic sugar for pointer arith" that moebius was talking about is somethig like a = *(a+i), where a is an...
Wed Jun 01, 2005 3:45 pm
Forum: C
Topic: Passing bidimentional mtrx to functions as pointer argument
Replies: 3
Views: 2192
it is possible to pass anything, it's just that things get complicated fast the more u reference. if u have int mat[N][M]; => void doSomething(int m[][M]); //or int *m[M] (this is an array of arrays of int) int *mat[M]; => void doSomething(int *m[M]); // or int **m (this is an array of pointers to i...
Wed Jun 01, 2005 3:13 pm
Forum: C
Topic: Exchanging two integers
Replies: 5
Views: 2977
besides, this is defined by ANSI C as undetermination:
a ^= b ^= a ^= b;
since u are trying to modify and access a variable in at the same point of execution.
it might work, but it's not portable.