Thread: Help me pleaseeeeeee ,I have a very hard problem in C language.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223
    - For the second point you could try converting (a copy of) the number to a character array & test each digit individually.
    - s < 1e19
    - use modulus
    Good luck, concentrate on doing one point at a time, not worrying about the limitations, then optimise.
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

  2. #2
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Wow, that homework is so easy, and you have a whole second to do it in...

    So like, do you not understand the problem? Or are you having a problem with your code?

    Basically its asking you to return some number OUTPUT (aka S) of which INPUT (aka N) is a factor, and S has to contain only the decimal digits 7 2 and 0.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    I see two obvious ways to attack this problem. Either test successive multiples of n until you find one with the right digits, or recursively generate all acceptable combinations of the allowed digits until you find one with a zero remainder.
    Either way, you'd need a 64-bit data type to do it since the problem description allows up to 20 digits.
    Well, that's just off the top of my head anyway.

    The best way to solve it is to try. Don't try and pretend, after being reminded of the homework policy, that it isn't homework. So many people do this that we get enough practice to see right through it every time.
    Last edited by iMalc; 02-21-2009 at 06:04 PM.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem and Solution
    By DavidP in forum Tech Board
    Replies: 3
    Last Post: 08-18-2003, 02:23 AM
  2. hard drive problems continually increasing
    By DavidP in forum Tech Board
    Replies: 5
    Last Post: 11-21-2002, 10:48 PM
  3. Hard Drive Problem
    By MethodMan in forum Tech Board
    Replies: 3
    Last Post: 10-08-2002, 05:13 PM
  4. Hard Problem :(
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 08-13-2002, 03:16 AM
  5. What can I do?
    By Unregistered in forum C++ Programming
    Replies: 27
    Last Post: 07-16-2002, 11:44 PM