Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <string.h>
  5. #include <stdbool.h>
  6. #include <math.h>
  7. #include <vector>
  8. #include <map>
  9. #include <set>
  10. #define pb push_back
  11. #define ll long long int
  12. #define ull unsigned long long int
  13. #define gcd(a,b) __gcd(a,b)
  14.  
  15. using namespace std;
  16.  
  17. int main()
  18. {
  19. //freopen("a.in","r",stdin);
  20. //freopen("a.out","w",stdout);
  21. // std::ios_base::sync_with_stdio(false);
  22. int t,q,num,chk=0,x;
  23. string s,T="",ch;
  24. cin>>t;
  25. while(t--){
  26. cin.clear();
  27. cin>>s;
  28. for(int i=0;i<s.length();i++){
  29. if(s[i]>='0' && s[i]<='9'){
  30. num = s[i]-48;
  31. num--;
  32. ch.clear();
  33. ch = T;
  34. for(int j=1;j<=num;j++){
  35. T += ch;
  36. }
  37. }else{
  38.  
  39. T += (char)s[i];
  40. }
  41. //cout<<T<<endl;
  42. }
  43. //cout<<T<<endl;
  44. int len = T.size();
  45. cin>>q;
  46. while(q--){
  47. cin>>x;
  48. if(x>len) cout<<-1<<endl;
  49. else cout<<T[x-1]<<endl;
  50. }
  51. }
  52.  
  53.  
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement