CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: msg555

Page 1 of 6 1 2 3 4

Search: Search took 0.08 seconds.

  1. Re: Is there any algorithm for this kind of a problem?

    I think that would work alright if you don't need an exact answer. In addition, you could run that algorithm multiple times and randomly shuffle the buyer and seller arrays each time.
  2. Re: Is there any algorithm for this kind of a problem?

    I don't see how you could set up the graph to get this into a max-flow problem. I also don't see how you could set this up as a bipartite matching because each buyer has a different buying power.
  3. Re: Is there any algorithm for this kind of a problem?

    I'm not really sure what you mean by 5. Anyway, a good start to a solution would be to write a recursive brute force method. Write a recursive procedure that tries to match buyers to a given seller...
  4. Re: Is there any algorithm for this kind of a problem?

    I'm sorry, I can't think of any polynomial solution to your problem. My best suggestion now is just to implement a Branch and Bound solution and hope that it can run fast enough for most inputs.
    ...
  5. Re: Is there any algorithm for this kind of a problem?

    well, if buyers could buy from multiple sellers and only partially buy their demand this would be a max flow problem. The additional constraints make this appear quite a bit harder. How many buyers...
  6. Re: Is there any algorithm for this kind of a problem?

    hmm, are you trying to maximize the number of things sold, or the number of buyers whose demand was completely satisfied?

    The latter isn't solvable with maxflow (as far as I can tell)

    btw,...
  7. Re: Is there any algorithm for this kind of a problem?

    What exactly is it that you are trying to optimize. If you are trying to maximize the number of things traded then this is a max flow problem.

    http://en.wikipedia.org/wiki/Maximum_flow_problem
    ...
  8. Replies
    7
    Views
    31,880

    Re: multiplicative inverse finding algorithm

    Suppose that you are trying to calculate the modular inverse of px (mod py). You would do it in the following way (written in c++)


    int x = px;
    int y = py;

    //Setup initial variables...
  9. Replies
    7
    Views
    31,880

    Re: multiplicative inverse finding algorithm

    to say that b is the modular inverse mod m of a is to say that

    a * b = 1 (mod m)

    for any integer a, there exist such an inverse b if and only if a and b are relatively prime. Using the...
  10. Replies
    13
    Views
    2,496

    Re: Keyboard Focus problem

    I posted how I felt. Even if it isn't how he meant to come off it's pretty important he realize he is coming off that way to me. It's really easy for people to misinterpret each other through...
  11. Replies
    13
    Views
    2,496

    Re: Keyboard Focus problem

    First, it's just a suggestion. I'm not sure what tone you intend your post to be read in, but it seems fairly aggressive which doesn't seem like an appropriate response to someone trying to help.
    ...
  12. Replies
    13
    Views
    2,496

    Re: Keyboard Focus problem

    It may help to make your menus unfocusable. This *may* solve your problem. Either way, if you use dlorde's solution you probably want to do this too. Consider what may happen if a button has focus...
  13. Thread: listing files

    by msg555
    Replies
    2
    Views
    848

    Re: listing files

    Most likely the problem is there is a bug in your code. Unfortunately, if we don't have the real code it's impossible to tell.

    There are some problems with your psuedocode however. If dir is a...
  14. Replies
    1
    Views
    1,547

    Re: dijkstra's algorithm for shortest path

    The problem is that changes you make to the distances in your objects are not reflected in the priority queue. This is because the priority queue has no way of knowing you made any changes.

    The...
  15. Replies
    4
    Views
    1,605

    Re: Finished with beginner stuff... what now?

    How about competitive programming? http://topcoder.com/tc
  16. Replies
    4
    Views
    1,555

    Re: Matrices multiplication algorithm

    You are correct in thinking that changing the outermost loops alone wouldn't do anything. The only real case I can think of is when p is 0 (which seems silly). Perhaps there is some sort of...
  17. Replies
    5
    Views
    1,632

    Re: how to get two figures after decimal point?

    True, one possible caveat is that floor is not the same as truncation for negative numbers. If it really matterse to the orpo they can just use ceil on negative numbers.
  18. Replies
    10
    Views
    1,972

    Re: rectangle problem

    Fair enough
  19. Replies
    5
    Views
    1,632

    Re: how to get two figures after decimal point?

    Assuming you don't want to round something like this will do.

    n = (int)(n * 100 + 1e-10) / 100.0;

    the " + 1e-10" part may not be necessary or it may need to be increased depending on the type...
  20. Replies
    10
    Views
    1,972

    Re: rectangle problem

    Does CodeGuru have any policies about just giving out answers in code? I think it's odd that there were two posts after mine that said the exact same thing just with more and more specific...
  21. Replies
    15
    Views
    4,133

    Re: C++ Struct analog

    In Java, you typically use the Comparable interface to make a class comparable. Comparators are only used if you want to change the way that an existing class is compared in a sort function or the...
  22. Replies
    15
    Views
    4,133

    Re: C++ Struct analog

    You will probably want to make a class that abstracts all the information in your GPS satellite info structure; time, id of satellite, x coordinate, y coordinate, z coordinate, ...

    Next you will...
  23. Replies
    10
    Views
    1,972

    Re: rectangle problem

    Maybe you should figure out why you have three closing braces at the end of your code. I think if you tab your code in a logical way you'll find the problem. I assume the way that it is formatted...
  24. Replies
    8
    Views
    1,791

    Re: Rotating of a pool ball

    Perhaps this will help

    http://en.wikipedia.org/wiki/Euler_angles

    I think, if applied correctly, this can do exactly what you want in a very clean way.

    Initially, let R be the identity...
  25. Replies
    8
    Views
    1,791

    Re: Rotating of a pool ball

    You'll need to find the amount of rotation along the axis of rotation (ie, perpendicular to the direction of movement in the same plane). You can find the correct rotation by first rotating the pool...
Results 1 to 25 of 142
Page 1 of 6 1 2 3 4





Click Here to Expand Forum to Full Width

Featured