Need Help in checking Testcases for "Buying candies "

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.