Thread: A little maths problem for you

  1. #46
    back? dbaryl's Avatar
    Join Date
    Oct 2001
    Posts
    597
    [EDIT]Highlited in red is incorrect!
    I pick A, B, C, and D to be prices for the items being sold (in cents). The product will look like this:
    A * B * C * D = 711
    (A * B * C) * D = 711
    >> 711 % (A * B * C) == 0


    What I mean by above is that EACH of the items bust be an INTEGER FACTOR of 711, in order to divide 711 cents by either of the prices and get an integer value in cents again. This is based on the assumption that the prices are integer values in cents, can't have a dicimal of a cent in price.

    Now, the integer factors of 711 are: 1, 3, 9, 79 and 237.

    This is the same as:

    $0.01, $0.03, $0.09, $0.79 or $2.37

    Let's theorize that all items are priced below $2.37, that is either $0.01, $0.03, $0.09 or $0.79. This would mean that you must be able to get a sum of $7.11 out of 4 items that are $0.79 or below, which is impossible. If only 1 item is $2.37, then the other 3 must add to 7.11 = 2.37 = 4.74 >> impossible again with 3 items below $1. So, at least 2 items must be priced at $2.37 each, leaving other 2 to be: 7.11 - (2 * 2.37) = 2.37

    As you can see, it's impossible to have 2 items priced $0.01, $0.03, $0.09, $0.79 or $2.37 to add to $2.37 without them being $0 and $2.37. Now, this again is impossible, because the product must be a non-zero value.

    I see no solution for this probem.
    Last edited by dbaryl; 05-21-2002 at 10:33 AM.
    This is my signature. Remind me to change it.

  2. #47
    Registered User Jet_Master's Avatar
    Join Date
    May 2002
    Posts
    291
    YES!!! Ha Ha Ha!!!

    This IS getting INTERESTING!!! Ha Ha Ha !!!

    I LOVE this thread!!!
    I am the Alpha and the Omega!!!

  3. #48
    Registered User Jet_Master's Avatar
    Join Date
    May 2002
    Posts
    291
    dbaryl, thanks a lot for the info you have provided. I WILL use all that to find any possible solution if possible. if not possible, i will not possibly find an answer that is possible and is correct. but if there is a possible answer, i possibly can find it! just wait for the possible; or for some, my accptance of the impossible.

    (either way, i am sure that i have confused you by now)
    I am the Alpha and the Omega!!!

  4. #49
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    There is an absolute answer... I once had a program written in C which calculated the answer(s) but I lost it when my HD crashed.

    I know the values, but the program would be damn cool to have now

  5. #50
    Registered User Jet_Master's Avatar
    Join Date
    May 2002
    Posts
    291
    the closest i could get was:
    the items cost $1.00, $2.91, $1.94, $1.26

    the sum is $7.11
    but the product is $7.113204 - when you round this up to two decimal points, i get: $7.11!!

    but, i didnot use programming. just my mind and a calculator.
    I am the Alpha and the Omega!!!

  6. #51
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Well, sadly, that's wrong. It's not an exact value..
    I may be able to recreate the program which calculated the answer, but I doubt it :/

  7. #52
    Registered User Jet_Master's Avatar
    Join Date
    May 2002
    Posts
    291
    >>Well, sadly, that's wrong. It's not an exact value..

    i thought so. my program cannot calculate anything. this is how my program is:
    i declared 4 variables - a,b,c,d

    a+b+c+d=7.11
    a*b*c*d=7.11

    isn't that right. correct me if i am wrong.

    also,
    a=7.11-(b+c+d)
    b=7.11-(a+c+d)
    c=7.11-(a+b+d)
    d=7.11-(a+b+c)

    when i do that, it calculates the first statement first. so, it gives my a value=7.11 and all others 0. so it satisfies the first part of my function. but i dont know why it neglects the part (a*b*c*d=7.11)


    i hope you understand what i am saying...
    I am the Alpha and the Omega!!!

  8. #53
    Unregistered
    Guest
    dbaryl is right

    but here's a piece of code that'll prove it:

    Code:
    #include <stdio.h>
    
    int main()
    {
       int i,j,k;
       int a,b,c,d;
    
       for(i = 1, a = 1; i <= 711; i++, a++)
       {
          for(j = 1, b = 1; j <= 711; j++, b++)
          {
             for(k = 1, c = 1; k <= 711; k++, c++)
             {
                d = 711 - a - b - c;
                if(a * b * c * d == 711)
                {
                   printf("a = %d\nb = %d\nc = %d\nd = %d\n", a, b, c, d);
                   return 0;
                }
             }
          }
       }
    
       printf("No such answer\n");
    
       return 0;
    }

  9. #54
    Unregistered
    Guest
    oops my bad

    here's the revised code:

    Code:
    #include <stdio.h>
    
    int main()
    {
       double a,b,c,d;
    
       for(a = 0; a <= 7.11; a += 0.01)
       {
          for(b = 0; b <= 7.11; b += 0.01)
          {
             for(c = 0; c <= 7.11; c += 0.01)
             {
                d = 7.11 - a - b - c;
                if(a * b * c * d == 7.11)
                {
                   printf("a = %d\nb = %d\nc = %d\nd = %d\n", a, b, c, d);
                   return 0;
                }
             }
          }
       }
    
       printf("No such answer\n");
    
       return 0;
    }

  10. #55
    back? dbaryl's Avatar
    Join Date
    Oct 2001
    Posts
    597
    Originally posted by Jet_Master
    dbaryl, thanks a lot for the info you have provided. I WILL use all that to find any possible solution if possible. if not possible, i will not possibly find an answer that is possible and is correct. but if there is a possible answer, i possibly can find it! just wait for the possible; or for some, my accptance of the impossible.

    (either way, i am sure that i have confused you by now)
    No, you didn't.
    This is my signature. Remind me to change it.

  11. #56
    back? dbaryl's Avatar
    Join Date
    Oct 2001
    Posts
    597
    Oh, a couple more things... those of you who say that there is a possible answer, the only way I see it is if the prices are some ugly "non-nice" decimal. If you check the first post on this page, that is where I show my thoughts on this... if you see anthing wrong, tell me, otherwise, my answer stands: no solution.

    Unregistered, how about this one?
    Code:
    #include <stdio.h>
    
    int main()
    {
       printf("No such answer!\n");
    
       return 0;
    }
    This is my signature. Remind me to change it.

  12. #57
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    Unregistered is on the right track... that is somewhat what the program looked like, but the logic is still off.
    If you check the first post on this page, that is where I show my thoughts on this... if you see anthing wrong, tell me, otherwise, my answer stands: no solution.
    Well, there is a solution, I have it right here... so I guess you're wrong :/

  13. #58
    back? dbaryl's Avatar
    Join Date
    Oct 2001
    Posts
    597
    Is my assumption incorrect? Or are the 3 values something other tahn int values of cents? Tell me that much.... pliz.
    This is my signature. Remind me to change it.

  14. #59
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    801
    I worte a progra the second i saw thins q, to figure out the ans I'm attaching it, I ran the damn thing for 8 hours, still no hit!!!!!!!!!!!!
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: [email protected] []*[]

  15. #60
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    801
    And here's the code
    PHP Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <string.h>
    #include <math.h>




    void main(){

    float a,b,c,d;

    for(;;){

    a= (rand() / 65654.356);    // I got these Numbers
    c= (rand() / 3215.265);      //by the rand() function
    b= (rand() / 3541.065);      // Therefore, they are 
    d= (rand() / 12456.265);    //random numbers!

    printf("\n%.2f + %.2f + %.2f + %.2f == %.2f"a,b,c,da+b+c+d);
    printf("\n %.2f * %.2f * %.2f * %.2f == %.2f"a,b,c,da*b*c*d);

    if( ((
    a+b+c+d)==7.11) && ((a*b*c*d)==7.11) ){

    system("pause");}
    }

    So what if it uses random numbers!!!!!!!!!!!!!!! it helps me not to fry my brain!!
    Last edited by Commander; 05-20-2002 at 07:34 PM.
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: [email protected] []*[]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  4. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 06:24 PM
  5. Maths problem
    By Zewu in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 11-13-2002, 02:34 PM