Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- int t;
- cin>>t;
- for(int j=0;j<t;j++) {
- long long int x;
- int b;
- cin>>b>>x;
- if (x==0) {cout<<"a"; return 0;}
- x++;
- unsigned long long int sum=0;
- int counter=1;
- while (sum<x) {
- sum+=pow(b,counter)*counter;
- counter++;
- }
- sum-=pow(b,counter-1)*(counter-1);
- x-=sum;
- int y=x%(counter-1);
- if (y==0) y=counter-1;
- x/=(counter-1);
- x--;
- int m = (int)(x/pow(b,counter-1-y))%b;
- char n=m+97;
- cout<<n<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement