daily pastebin goal
7%
SHARE
TWEET

52

ArchiaterFaun Dec 7th, 2017 (edited) 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int a=0,q,p;
  8.     string s;
  9.     cin>>s>>q;
  10.     vector <int> k;
  11.     for (int i=0;i<s.size();i++)
  12.     {
  13.         if (s[i]=='+')
  14.         {
  15.             a+=2;
  16.         }
  17.         else if (s[i]=='/')
  18.         {
  19.             a/=2;
  20.         }
  21.         else if (s[i]=='*')
  22.         {
  23.             a*=2;
  24.         }
  25.         else if (s[i]=='-')
  26.         {
  27.             a-=2;
  28.         }
  29.         k.push_back(a);
  30.     }
  31.     for (int j=0;j<q;j++)
  32.     {
  33.         cin>>p;
  34.         cout<<k[p-1]<<' ';
  35.     }
  36.  
  37.     return 0;
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top