I too got the same issue, the input range is about 10^100 which we can't do 
in c++. We should be able to run the testCase 1 but i couldn't pass it, 
don't know why.
https://groups.google.com/d/msg/google-code/4bE6EYLAbHU/UTlasQXpAwAJ

On Monday, March 30, 2020 at 6:01:31 AM UTC+5:30, Karim Elghamry wrote:
>
> #include <iostream>
> #include <string>
> #include <vector>
> #include <utility>
> #include <map>
> #include <cmath>
>
> std::pair<int, int> primeFac(int n);
>
> int main()
> {
>     int t, l, n, k = 1;
>     std::vector<int> input, primes;
>     std::map<int, char> sortedPrimes;
>     std::string output;
>     std::cin >> t;
>
>     while (t--)
>     {
>         std::cin >> n >> l;
>         input.clear();
>         primes.clear();
>         sortedPrimes.clear();
>         output = "";
>         for (int i = 0; i < l; i++)
>         {
>             int temp;
>             std::cin >> temp;
>             input.push_back(temp);
>         }
>
>         std::pair<int, int> eminem = primeFac(input[0]);
>         int first = input[1] % eminem.first == 0 ? eminem.second :
>  eminem.first;
>         int second = first == eminem.first ? eminem.second : eminem.first;
>         primes.push_back(first);
>         sortedPrimes[first] = 'a';
>         primes.push_back(second);
>         sortedPrimes[second] = 'a';
>         for (int i = 1; i < l; i++)
>         {
>             int temp = input[i] / primes[i];
>             primes.push_back(temp);
>             sortedPrimes[temp] = 'a';
>         }
>
>         int i = 0;
>         for (auto &c : sortedPrimes)
>         {
>             c.second = 'A' + i;
>             i++;
>         }
>
>         for (auto c : primes)
>         {
>             output += sortedPrimes[c];
>         }
>         std::cout << "Case #" << k << ": " << output << std::endl;
>
>         k++;
>     }
>
>     return 0;
> }
>
> std::pair<int, int> primeFac(int n)
> {
>     std::pair<int, int> temp;
>
>     for (int i = 3; i < sqrt(n); i = i + 2)
>     {
>         if (n % i == 0)
>         {
>             temp.first = i;
>             temp.second = n / i;
>             return temp;
>         }
>     }
>
>     return temp;
> }
>
> It runs fine for the input samples but gives RE on test set 1, why?
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/1d2df1ba-16f3-4694-9da6-ad517b0b56da%40googlegroups.com.

Reply via email to