Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C++ Compiler.
- Code, Compile, Run and Debug C++ program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- #include <map>
- using namespace std;
- map <char, int> L;
- int nm(string x){
- reverse(x.begin(), x.end());
- int sz = x.size();
- int res = 0;
- for (int i=0;i<sz;++i){
- res += pow(26, i) * L[x[i]];
- }
- return res;
- }
- int main()
- {
- int cnt = 1;
- for (int i = 65; i <= 90;++i){
- char l = i;
- //cout<<"l= "<<l<<' '<<cnt<<'\n';
- L[l] = cnt;
- cnt++;
- }
- //for (auto x: L)cout<<x.first<<' '<<x.second<<'\n';
- cout<<nm("AA");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement