Ad
  • Custom User Avatar

    Are you sure you get invalid answers with this code on CW? I ran it several times and all I got were timeouts, and not a single wrong answer.

    Also you could work on your factoriazation method a bit. It first goes through the number too many times, and then unneccessarily scans the collection of factors many times. These operations can be reduced significantly to, more or less, one loop over the part of the number, and eventually one loop over the collected factors.

  • Custom User Avatar

    Then you have to show us your code, I think it will be the easiest way to find your mistake. Remember about formatting and spoiler flag.

  • Custom User Avatar

    You should check if your solution works good when run twice in a row, for two or more test cases run one after another.