Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cstdio>
  4. #include <stdio.h>
  5. #include <cstdlib>
  6. #include <bitset>
  7. #include <memory>
  8. #include <algorithm>
  9. #include <set>
  10. #include <map>
  11. #include <vector>
  12. #include <list>
  13. #include <string>
  14. #include <cstring>
  15. #include <fstream>
  16. #include <functional>
  17. #include <stack>
  18. #include <complex>
  19. #include <wchar.h>
  20. #include <wctype.h>
  21. #include <cmath>
  22. #include <queue>
  23. #include <ctime>
  24. #include <numeric>
  25. #include <bitset>
  26. #include <cassert>
  27.  
  28.  
  29. using namespace std;
  30.  
  31. template<typename T> T mabs(const T &a){ return a<0?-a:a;}
  32. #define rep(x,y,z) for(int x=(y),e##x=(z);x<e##x;x++)
  33. #define SQR(x) ((x)*(x))
  34. #define all(c) (c).begin(), (c).end()
  35.  
  36. typedef long long ll;
  37. typedef long double ld;
  38. typedef unsigned long long ull;
  39. typedef unsigned int ui;
  40. typedef short int si;
  41. typedef pair<int,int> pii;
  42. typedef pair<ll,ll> pll;
  43. typedef pair<double, int> pdi;
  44. typedef pair<double, double> pdd;
  45.  
  46.  
  47.  
  48. void run()
  49. {
  50.     int n;
  51.     cin>>n;
  52.     char str[100];
  53.     scanf("%s",str);
  54.     reverse(str, str+strlen(str));
  55.     char pos = 'A';
  56.     ll res = 0;
  57.     rep(i,0,n)
  58.     {
  59.         if (str[i] != pos)
  60.         {
  61.             pos = 'A' + 'B' + 'C' - str[i] - pos;
  62.             res += (1LL<<(n-i-1));
  63.         }
  64.     }
  65.     cout<<res<<endl;
  66. }
  67.  
  68.  
  69.  
  70.  
  71. int main()
  72. {
  73. #ifdef _MONYURA_
  74. #ifdef prob
  75.     freopen(prob".in","r",stdin);
  76.     freopen(prob".out","w",stdout);
  77. #else
  78.     freopen("test.in","r",stdin);
  79.     freopen("test.out","w",stdout);
  80. #endif
  81.     time_t st=clock();
  82. #else
  83. #ifdef prob
  84.     freopen(prob".in","r",stdin);
  85.     freopen(prob".out","w",stdout);
  86. #endif
  87. #endif
  88.     run();
  89. #ifdef _MONYURA_
  90. #ifndef prob
  91.     printf( "\n=============\n");
  92.     printf("Time: %.2lf sec\n",(clock()-st)/double(CLOCKS_PER_SEC));
  93. #endif
  94. #endif
  95.    
  96.     return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement