Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define maxN 1111115
- using namespace std;
- int findval(long long pos,long long putere)
- {
- if(pos==1)
- return 1;
- if(putere==4)
- {
- if(pos==1) return 1;
- if(pos==2) return 0;
- if(pos==3) return 0;
- if(pos==4) return 1;
- }
- long long aux=putere/4;
- if(1<=pos && pos<=aux)
- return findval(pos,putere/4);
- if(aux<pos && pos<=aux*2)
- return 1-findval(pos-aux,putere/4);
- if(aux*2<pos && pos<=aux*3)
- return 1-findval(pos-2*aux,putere/4);
- if(aux*3<pos && pos<=aux*4)
- return findval(pos-3*aux,putere/4);
- }
- char caracter(long long n)
- {
- char c;
- long long putere=1;
- while(putere<=n)
- putere*=4;
- if(putere==4*n)
- putere/=4;
- int aux=findval(n,putere);
- if(aux==1)
- c='A';
- else c='T';
- return c;
- }
- inline bool putere(long long x)
- {
- return !(x&(x-1));
- }
- int main()
- {
- int n;
- cin>>n;
- char actual,precedent='$';
- long long len=0;
- long long maxx=-1;
- for(int i=1;i<=n;i++)
- {
- long long x;
- cin>>x;
- actual=caracter(x);
- if(actual=='T' && precedent=='T')
- len++;
- else
- {
- if(putere(len+1)&&precedent=='T')
- maxx=max(maxx,len);
- if(actual=='T')
- len=1;
- else len=0;
- }
- precedent=actual;
- }
- if(maxx==-1)
- cout<<"NU EXISTA";
- else
- cout<<maxx;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement