Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- string str;
- vector<char>str2;
- int i,j,t,n,ln,tln,fac,div,x,y;
- cin>>t;
- while(t--){
- cin>>str;
- cin>>n;
- ln=str.size();
- tln=ln;
- y=0;
- while(y<ln){
- fac=1;
- for(j=1;j<=tln;j++)
- fac=fac*j;
- div=fac/ln;
- x=n/div;
- str2.push_back(str[x]);
- str.erase(str.begin()+(x+1));
- n=n-div*x;
- y++;
- tln--;
- }
- for(j=0;j<ln;j++)
- cout<<str2[j];
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement