Guest User

Untitled

a guest
Dec 23rd, 2016
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.59 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5. class Task
  6. {
  7.     public:
  8.        void solve(istream& in,ostream& out)
  9.        {
  10.           string s;
  11.           cin >>s;
  12.           ll n=s.length();
  13.           char seat=s[n-1];
  14.           ll a=atol(s.substr(0,n-1).c_str());
  15.           ll res;
  16.  
  17.           if (a%4==1)
  18.           {
  19.               ll x=a-1;
  20.               res=(x/4)*12+x+(index(seat));
  21.           }
  22.  
  23.           else if (a%4==2)
  24.           {
  25.               ll x=a-2;
  26.               res=(x/4)*12+x+(index(seat));
  27.               res+=7;
  28.           }
  29.  
  30.           else if (a%4==3)
  31.           {
  32.               a=a-2;
  33.               ll x=a-1;
  34.               res=(x/4)*12+x+(index(seat));
  35.           }
  36.  
  37.           else if (a%4==0)
  38.           {
  39.               a-=2;
  40.               ll x=a-2;
  41.               res=(x/4)*12+x+(index(seat));
  42.               res+=7;
  43.           }
  44.  
  45.           cout <<res<<endl;
  46.        }
  47.  
  48.        ll index(char a)
  49.        {
  50.           if (a=='f')
  51.           {
  52.              return 1;
  53.           }
  54.           else if (a=='e')
  55.           {
  56.              return 2;
  57.           }
  58.           else if (a=='d')
  59.           {
  60.              return 3;
  61.           }
  62.           else if (a=='a')
  63.           {
  64.              return 4;
  65.           }
  66.           else if (a=='b')
  67.           {
  68.              return 5;
  69.           }
  70.           else
  71.           {
  72.              return 6;
  73.           }
  74.        }
  75.  
  76. };
  77. int main()
  78. {
  79.     ios_base::sync_with_stdio(false);
  80.     cin.tie(NULL);
  81.     istream& in(cin);
  82.     ostream& out(cout);
  83.     Task solver;
  84.     solver.solve(in,out);
  85.     return 0;
  86. }
Add Comment
Please, Sign In to add comment