Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main() {
- int i,t,n;
- cin>>t;
- while(t--)
- {
- cin>>n;
- string s="";
- while(n>0)
- {
- i=n%26;
- if(i==0){s+='Z'; n--;}
- else s+='A'+i-1;
- n/=26;
- }
- reverse(s.begin(),s.end());
- cout<<s<<endl;
- }
- return 0;
- }
- ------------
- int titleToNumber(string s)
- {
- int result = 0;
- for (const auto& c : s)
- {
- result *= 26;
- result += c - 'A' + 1;
- }
- return result;
- }
Add Comment
Please, Sign In to add comment