Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <cmath>
- using namespace std;
- ifstream fin("binar.in");
- ofstream fout("binar.out");
- int n,i,x,a,f,j,v[500001],b,k,ap[3],Max,numar,r[500001],c,r2[500001],ok,l,Max2,p;
- int main()
- {
- fin>>c;
- fin>>n;
- for(i=1;i<=n;i++){
- fin>>x;
- r[i] = x;
- a = 0;
- f = 0;
- for(j=0;j<=2;j++){
- ap[j] = 0;
- }
- while(x){
- a = x % 2;
- ap[a]++;
- f++;
- v[f] = a;
- x = x / 2;
- }
- r2[i] = ap[1];
- if(ap[1]>Max){
- Max = ap[1];
- numar = r[i];
- }
- else if(ap[1]==Max){
- if(r[i]>numar){
- numar = r[i];
- }
- }
- k = f - 1;
- b = 0;
- for(j=f;j>=0;j--){
- b = b + v[j]*pow(10,k);
- k--;
- }
- }
- if(c==1){
- fout << numar << endl;
- }
- l = 0;
- ok = 0;
- for(i=1;i<=n;i++){
- if(ok==1 && r2[i]==r2[i+1]){
- l++;
- if(l>Max2){
- Max2 = l;
- }
- }
- if(ok==1 && r2[i]!=r2[i+1]){
- ok = 0;
- l = 0;
- }
- if(r2[i]==r2[i+1] && ok == 0){
- ok = 1;
- l++;
- if(l>Max2){
- Max2 = l;
- p = i;
- }
- }
- }
- if(c==2){
- if(p<=0){
- p = 1;
- }
- fout << Max2 + 1 << " " << p << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement