Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<algorithm>
- #include<iostream>
- #include<iomanip>
- #include<stdio.h>
- #include<bitset>
- #include<vector>
- #include<string>
- #include<queue>
- #include<cmath>
- #include<ctime>
- #include<stack>
- #include<map>
- #include<set>
- using namespace std;
- typedef long long LL;
- typedef long double LD;
- typedef pair<LL,LL> PLL;
- typedef pair<LD,LD> PDD;
- typedef pair<int,int> PII;
- typedef pair<PII,PII> PPII;
- #define PRINT(a) cerr<<#a<<" = "<<(a)<<'\n'
- #define B_E(a) a.begin(), a.end()
- #define PB push_back
- #define MP make_pair
- #define S second
- #define F first
- inline void file() {
- #ifdef _WIN32
- srand(time(NULL));
- return;
- #endif
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- if (0) {
- freopen(".in", "r", stdin);
- freopen(".out", "w", stdout);
- }
- }
- inline void read(int& n) {
- #define nxt h = getchar_unlocked()
- #define nxt h = getchar()
- char h; n = 0;
- for (nxt; h<'0' || h>'9'; nxt);
- for (; h>='0' && h<='9'; nxt)
- n = n*10 + h-'0';
- #undef nxt
- }
- const clock_t MAXT = (100*CLOCKS_PER_SEC)/1000;
- const int PX[8] = {1,0,-1,0, 1,1,-1,-1},
- PY[8] = {0,1,0,-1, -1,1,1,-1},
- N = 1e5 + 10,
- INF = 1e9,
- MOD = 1e9 + 7;
- const LL INFL = 1e18,
- MODL = 1e9 + 7;
- const LD EPS = 1e-6;
- inline int rnd(int l = 0, int r = INF) {
- unsigned ans = rand();
- ans = (ans<<8) ^ rand();
- ans = (ans<<8) ^ rand();
- ans = (ans<<8) ^ rand();
- ans %= r-l+1;
- return int(ans + l);
- }
- int n;
- inline LL get(string s) {
- s = " " + s;
- for (int i=n; i; --i)
- switch (s[i]) {
- case 'A':
- s[i] = 0;
- break;
- case 'B':
- s[i] = 1;
- break;
- case 'C':
- s[i] = 2;
- break;
- case 'D':
- s[i] = 0;
- break;
- case 'E':
- s[i] = 1;
- break;
- }
- //for (int i=1; i<=n; ++i) cout<<+s[i]; cout<<'\n';
- LL ans = 0;
- for (int i=1; i<=n; ++i) {
- if ( !(i&1) ) ans *= 2;
- else ans *= 3;
- ans += s[i];
- }
- return ans;
- }
- inline LL solve(LL l, LL r) {
- if ( l == r )
- return 0;
- if ( r < l )
- swap(l,r);
- return r - l - 1;
- }
- main()
- { file();
- string s;
- LL l,r;
- cin>>s;
- n = s.size();
- l = get(s);
- cin>>s;
- r = get(s);
- cerr<<' '<<l<<' '<<r<<'\n';
- cout<<solve(l,r)<<'\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement