Thanks for quick response, please update the standings if possible.
hey, bud can u explain to me âŚin 3rd question i.e. âPoreee geloooâ how in the last test case i.e.
" adoreee gelooo" the answer is 30 and similarly how âbaoreee geloooâ is 53.
yeah sure, first off ,it should be obvious that the second string is useless and the last 5 characters are redundant in the first string. So of the remaining letters like for " adoreee gelooo" the remaining string is âadâ, if you write âadâ in base 26 will be 14 (1->a and 4->b ), so the number 14_{26} will be 26*1+4 = 30 , similarly itâs 53 for âbaoreee geloooâ . This code should make the idea clear,
AC_CODE
#include <bits/stdc++.h>
using namespace std;
void solve(){
int ans =0 ;
string s,t ;
cin >> s >> t ;
reverse(s.begin(),s.end()) ;
string a = s.substr(5);
for(int i=0,j=1;i<a.size();i++,j*=26)
ans+=(a[i]-'a'+1)*j ;
cout << ans << '\n' ;
}
signed main() {
int t ;
cin >> t ;
while(t--)
solve() ;
}
2 Likes
Thanks for the explanation.