Did the exact same and got wrong answer during competition. Didnt know why
till now

On Wed, Apr 10, 2019 at 3:38 AM Kartikey Tewari <[email protected]>
wrote:

> #include <iostream>
> #include <algorithm>
> using namespace std;
>
> int gcd (int a,int b)
> {
>         if (a==b)
>         {
>                 return a;
>         }
>         if (a<b)
>         {
>                 return gcd(a,b-a);
>         }
>         if (b<a)
>         {
>                 return gcd(b,a-b);
>         }
> }
>
> int main()
> {
>         int t;
>         cin >> t;
>         for (int y=1;y<=t;y++)
>         {
>                 int n,l;
>                 cin >> n >> l;
>                 int arr[l];
>                 int number[l+1];
>
>                 for (int i=0;i<=l-1;i++)
>                 {
>                         cin >> arr[i];
>                 }
>
>                 for (int i=1;i<=l-1;i++)
>                 {
>                         number[i]=gcd(arr[i],arr[i-1]);
>                 }
>                 number[0]=arr[0]/number[1];
>                 number[l]=arr[l-1]/number[l-1];
>
>                 int key[l+1];
>                 for (int i=0;i<=l;i++)
>                 {
>                         key[i]=number[i];
>                 }
>                 sort(key,key+l+1);
>                 int alphabet[100];
>                 int j=1;
>                 alphabet[0]=key[0];
>
>                 for (int i=1;i<=l;i++)
>                 {
>                         if (key[i]!=key[i-1])
>                         {
>                                 alphabet[j]=key[i];
>                                 j++;
>                         }
>                 }
>
>                 cout << "Case #" << y << ": ";
>                 for (int i=0;i<=l;i++)
>                 {
>                         for (int k=0;k<=j-1;k++)
>                         {
>                                 if (number[i]==alphabet[k])
>                                 {
>                                         cout << char(k+65);
>                                 }
>                         }
>                 }
>
>                 cout << endl;
>         }
>
>         return 0;
> }
>
> --
> 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/13377253-0c90-4843-8cb3-9cc6ab6ba9d6%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAF-tymbe5t8H_bNxDPTBU8x8avq17m%2B0J%3DDoun4Y-V_BvTo9pw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to