Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cstdio>
- #include <stdio.h>
- #include <cstdlib>
- #include <bitset>
- #include <memory>
- #include <algorithm>
- #include <set>
- #include <map>
- #include <vector>
- #include <list>
- #include <string>
- #include <cstring>
- #include <fstream>
- #include <functional>
- #include <stack>
- #include <complex>
- #include <wchar.h>
- #include <wctype.h>
- #include <cmath>
- #include <queue>
- #include <ctime>
- #include <numeric>
- #include <bitset>
- #include <cassert>
- using namespace std;
- template<typename T> T mabs(const T &a){ return a<0?-a:a;}
- #define rep(x,y,z) for(int x=(y),e##x=(z);x<e##x;x++)
- #define SQR(x) ((x)*(x))
- #define all(c) (c).begin(), (c).end()
- typedef long long ll;
- typedef long double ld;
- typedef unsigned long long ull;
- typedef unsigned int ui;
- typedef short int si;
- typedef pair<int,int> pii;
- typedef pair<ll,ll> pll;
- typedef pair<double, int> pdi;
- typedef pair<double, double> pdd;
- void run()
- {
- int n;
- cin>>n;
- char str[100];
- scanf("%s",str);
- reverse(str, str+strlen(str));
- char pos = 'A';
- ll res = 0;
- rep(i,0,n)
- {
- if (str[i] != pos)
- {
- pos = 'A' + 'B' + 'C' - str[i] - pos;
- res += (1LL<<(n-i-1));
- }
- }
- cout<<res<<endl;
- }
- int main()
- {
- #ifdef _MONYURA_
- #ifdef prob
- freopen(prob".in","r",stdin);
- freopen(prob".out","w",stdout);
- #else
- freopen("test.in","r",stdin);
- freopen("test.out","w",stdout);
- #endif
- time_t st=clock();
- #else
- #ifdef prob
- freopen(prob".in","r",stdin);
- freopen(prob".out","w",stdout);
- #endif
- #endif
- run();
- #ifdef _MONYURA_
- #ifndef prob
- printf( "\n=============\n");
- printf("Time: %.2lf sec\n",(clock()-st)/double(CLOCKS_PER_SEC));
- #endif
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement