On Monday, April 8, 2019 at 5:36:54 AM UTC+8, thierry njike wrote: > hello, > is anybody here who codes in C++ please? i've also got a Runtime error for > the cryptopangan problem even if i got the same output with the sample test. > that's my code below: > > #include <iostream> > #include <vector> > #include <string> > #include <algorithm> > using namespace std; > > pair<int, int> factor(int n); > int main() > [omitted] > }
Two of the same letter consecutively could produce a square number, which is not handled correctly by your factor function -- it will set p.first to the prime number but fail to set p.second. When the first two pairs have the same two primes, they could be split either way, and your program may do it the wrong way. For example: Original primes: 3, 101, 3, 5, 2, ... Ciphertext: 303, 303, 15, 10, ... Your program gives: 101, 3, 101, 15/101 = 0, 10/0 [error: division by zero] -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/b90293c7-bbf8-484c-8822-e1e2a83e3506%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
