Maybe there's a typo, but that input case is invalid because '4' is not part of the source language.
Carlos Guía On Thu, Mar 5, 2015 at 5:45 AM, Dinesh Kumar <[email protected]> wrote: > Here is a question of google code jam alien numbers. > > I tried this question many times but was not able to get a perfect > solution. > > My code is > > #include<bits/stdc++.h> > using namespace std; > int main() { > freopen("input.txt","rt",stdin); > freopen("output.txt","wt",stdout); > int t; > cin>>t>>ws; > for(int e=1;e<=t;e++) > { > string a,b,c; > cin>>a>>b>>c; > map<char,int>pre; > for(int i=0;i<b.size();i++) > { > pre[b[i]]=i; > } > > int sum=0;int j=0; > for(int i=a.size()-1;i>=0;i--) > { > sum+=pre[a[j++]]*pow(b.size(),i); > } > map<int,char>post; > for(int i=0;i<c.size();i++) > { > post[i]=c[i]; > } > string temp=""; > int d; > while(sum!=0) > { > d=sum%c.size(); > temp=post[d]+temp; > sum=sum/c.size(); > } > cout<<"Case #"<<e<<": "<<temp<<endl; > } > getchar(); > return 0; > } > My solution for this sample input > > <-"i4g mkQxoGV{?T;7yvR_l3B-ti/ag6.%ews[8 u%v > is > > %%u%%vu%u%vvu%%u%v% > But the correct one is > > %%u%%vu%u%vvu%%u%vv > I get outputs similar except the last character in almost all cases. > Thought a lot of times about this but was unable to get myself correct. > Please help me out.... > > Thanx in advance.. > > -- > 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/daff2e31-836e-4d4d-a146-9e388aeb6c88%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/CANxkOGZ62nUJ7EsbzoV52fezApkHYUGTV5JPT3mZXo%3DuEVkpdQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
