Forum: C++ Oct 28th, 2008 |
| Replies: 8 Views: 929 ehh, now i'm confused... it would be helpful to see some code you've done already, but this is my suggestion: don't use a stack. it's a maze... a pretty straightforward graph. if you know where you... |
Forum: C++ Oct 27th, 2008 |
| Replies: 3 Views: 366 depends on what it's supposed to do :) |
Forum: C++ Oct 27th, 2008 |
| Replies: 3 Views: 288 hmm, define test case...? i don't get it... you can write some numbers onto a piece of paper, add them up and divide by the their quantity... enter those numbers into your program and check if the... |
Forum: C++ Oct 23rd, 2008 |
| Replies: 11 Views: 959 you're assuming too much, nobody guarantees any of those cases you mentioned. x1 < x2? why? it can be the opposite! also.. it isn't true that union is the area of the overlap.. it's the total area... |
Forum: C++ Oct 22nd, 2008 |
| Replies: 11 Views: 959 hmm, union of n rectangles, each defined by only two points, the segments are parallel with the lines of the system (x and y). |
Forum: C++ Oct 22nd, 2008 |
| Replies: 11 Views: 959 okay, so i've tried...hard, seriously. and i'm stuck. i've implemented the events, and an imaginary set to hold them in, but i'm stuck at the actual sweeping part. the problem i'm trying to solve is... |
Forum: C++ Oct 20th, 2008 |
| Replies: 11 Views: 959 i would, but i'm really not talented in implementing something from scratch, my first mergesort took 10 secs to sort 100 integers, and even then, they weren't sorted. with msort it was easy cause i... |
Forum: C++ Oct 20th, 2008 |
| Replies: 11 Views: 959 heya... ok, so i was browsing the net to find out if there's a good text on this algorithm, but i don't seem to be able to find one. people are obviously using it, but, hey, there's no info on it.... |
Forum: C++ Oct 18th, 2008 |
| Replies: 2 Views: 308 okay, so i came up with this idea of making a program to evaluate my code. it's supposed to take the code, compile it, run it on several test cases (given in one file each) and report how the code... |
Forum: C++ Oct 15th, 2008 |
| Replies: 5 Views: 368 but i need the minimum...that's not the minimum...try for example with dimensions 6*7... |
Forum: C++ Oct 15th, 2008 |
| Replies: 5 Views: 368 okay...i've got another wired counting problem, this time it's about rectangles!
gotta find the minimum number of lines to divide a rectangle into squares! i went for...ehh
well a dumb idea of... |
Forum: C++ Oct 10th, 2008 |
| Replies: 12 Views: 2,325 umm, sorry if it was not understandable, i tried to come up with a very long name for a type i want to define... so i made the name myself, don't try it it won't work. unless you define such a class.... |
Forum: C++ Oct 10th, 2008 |
| Replies: 17 Views: 1,396 do you think the same thing when discussing algorithms with O(2^n) time complexity? poor tin cans would struggle for centuries if n was...say 100. |
Forum: C++ Oct 10th, 2008 |
| Replies: 19 Views: 1,473 you can access them by memory addresses... so the integers should be given addresses that are consecutive. could count as pointing really. |
Forum: C++ Oct 10th, 2008 |
| Replies: 12 Views: 2,325 yea, you gotta either macro it or typedef with specifying the actual template type :P sucks in a way... but hey, what's the deal with the box thing, it's pretty small and easy to write...
i use... |
Forum: C++ Oct 10th, 2008 |
| Replies: 17 Views: 1,396 hehe, i'm lazy too, but i still wanna speed it up. found another way, without recursion, the idea is: no need to check for 1's, they always give 1, and 2's always give ( n/2 )+1...
still too slow :( |
Forum: C++ Oct 10th, 2008 |
| Replies: 17 Views: 1,396 hmm, okay...that's fast... reps to you!
//edit
umm it's not that fast, i see now, mine is alot faster, you haven't optimized the recursion, so you're making calls that aren't needed... mine goes... |
Forum: C++ Oct 9th, 2008 |
| Replies: 17 Views: 1,396 hmm, well now i've implemented it, but it's so damn slow... it should work fast for 100k atleast... here's my implementation:
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MOD... |
Forum: C++ Oct 9th, 2008 |
| Replies: 17 Views: 1,396 lol, i get it now finally... i thought i'm supposed to go from the largest coin down every time...that would be just sick. |
Forum: C++ Oct 8th, 2008 |
| Replies: 17 Views: 1,396 i mean, for example 3 has 2 solutions: 1+1+1 and 2+1, so if i go your way, i'll first take 2 off of the once and run the recursion on 3-2=1
which will give 1 solution. then i'll go down to 1, and... |
Forum: C++ Oct 8th, 2008 |
| Replies: 17 Views: 1,396 hmmm, could i please get a more detailed explanation? |
Forum: C++ Oct 8th, 2008 |
| Replies: 17 Views: 1,396 hmm, yeah, but how can it be done in some reasonable time? |
Forum: C++ Oct 8th, 2008 |
| Replies: 17 Views: 1,396 okay, this is the problem (variation of the knapsack coins problem): you've got 4 coin types:
1 cent, 2 cents, 5 cents and a quarter...infinite amount of each. I'm supposed to find the number of... |
Forum: C++ Oct 7th, 2008 |
| Replies: 8 Views: 880 hmm, but is there a way to shorten it, i got the concept of doing it recursively, but all i need is a limit for the number so i don't overflow the stack, also, is there a way to cut it on time by... |
Forum: C++ Oct 7th, 2008 |
| Replies: 8 Views: 880 @WaltP
umm, dfs? how do you mean dfs, what you mentioned seems like trying all possibilities... |
Forum: C++ Oct 6th, 2008 |
| Replies: 8 Views: 880 it's about having a board with 9 numbers, 1-9 obviously. they are organized in a 3*3 matrix.
the solved problem looks like:
123
456
789
the problem is, you are given a scrambled matrix, and you... |
Forum: C++ Oct 6th, 2008 |
| Replies: 12 Views: 1,391 i still don't really get it... if the input is in shape of (ax+b)(cx+d) you can easily solve this to acx^2+x(ad+bc)+bd, which you can simply extract from your string looking at them as being just... |
Forum: C++ Oct 6th, 2008 |
| Replies: 8 Views: 880 okay, i don't have a problem coding the game... that part would be easy. but the problem is to output the lease number of rotations needed to complete the game, so for example...
123 => 413
456 =>... |
Forum: C++ Oct 2nd, 2008 |
| Replies: 5 Views: 423 well... i'm not that good with c++ I/O (c ftw), but if you're using fstream, you can make two streams and use them for I/O, for example if the input stream is called 'input' you can go with while(... |
Forum: C++ Oct 2nd, 2008 |
| Replies: 12 Views: 1,391 if you could post a more detailed description of the problem... if you're only working with square binomials it should be really simple.
for example, if the shape of the input is
ax^2 + bx + c,... |
Forum: C++ Sep 30th, 2008 |
| Replies: 5 Views: 1,212 well if you know the exact position of those chars you can easily extract them from the string you read them in... for example, the given the position and length of the integer, you could go with... |
Forum: C++ Sep 30th, 2008 |
| Replies: 35 Views: 3,195 well this is a simple implementation of the sieve... #include <cstdio>
#define MAX 100000
bool prime[ MAX ];
void sieve() {
for( int i = 0; i < MAX; ++i ) prime[i] = 1;
prime[1] =... |
Forum: C++ Sep 30th, 2008 |
| Replies: 4 Views: 1,689 also can be done recursively..but stack almost equals recursion... for example:
#include <iostream>
#include <string>
using namespace std;
void do_the_stuff() {
char c; c = getchar();
... |
Forum: C++ Sep 30th, 2008 |
| Replies: 4 Views: 2,156 nah, math only gives full rounding, not precision. |
Forum: C++ Sep 30th, 2008 |
| Replies: 4 Views: 2,156 every time i make my own rounding routine with precision, i see my compiler suggesting a function long double round(long double x, int precision); so i was wondering if someone knows what library it... |
Forum: Troubleshooting Dead Machines Sep 28th, 2008 |
| Replies: 2 Views: 551 also, the motherboard leds aren't lighting, which indicates abnormal cpu or chipset error, well atleast it says so in the manual... |
Forum: Troubleshooting Dead Machines Sep 28th, 2008 |
| Replies: 2 Views: 551 i got myself a big pile of components yesterday, an amd dual core procesor, a new motherboard (biostar ta770 a2+) and a new graphics card, nvidia(club3d geforce 9600gt overlocked). so now i've put it... |
Forum: C++ Sep 27th, 2008 |
| Replies: 6 Views: 1,243 well i guess it can really be done without DP, as it is not really limited and can be done by going through the sorted array of items from the end to the start, if an item is larger than limit, limit... |
Forum: C++ Sep 27th, 2008 |
| Replies: 6 Views: 1,243 a simple loop? could you please tell me what algorithm would that be? cause recursion would go O(n!), would have to check all the combinations, also i didn't say, there are no unlimited supplies of... |
Forum: C++ Sep 27th, 2008 |
| Replies: 6 Views: 1,243 ok, so this is my problem...
i have an array of items, which i want to sum to x or above in a most efficient way...
is there a way for doing this? cause all the values are 64 bit ints.
i tried... |