Skip to content

Instantly share code, notes, and snippets.

@adis-io
Created November 5, 2012 18:03
Show Gist options
  • Select an option

  • Save adis-io/4019323 to your computer and use it in GitHub Desktop.

Select an option

Save adis-io/4019323 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int asd(int a) {
if (a % 8==0)
return 3;
if (a % 4==0)
return 2;
if (a % 2==0)
return 1;
return 0;
}
void mas_rec(int n, int *arr, int *mar) {
int i;
for (i=0; i<n;i++){
if (arr[i]==0)
arr[i]=3;
else {
arr[i]=asd(arr[i]);
}
};
for (i=0; i<4; i++)
mar[i]=0;
for (i=0; i<n; i++)
mar[arr[i]]+=1;
}
int pow(int val, unsigned int P)
{
int r = val;
if (P>0) {
while (--P)
r *= val;
return r;
} else
return 1;
}
int main(void) {
int arr[100];
int mar[4];
int i,n=0;
cin >> n;
for (i=0; i<n; i++)
cin >> arr[i];
mas_rec(n, arr, mar);
i=pow(2,n) - pow(2,mar[0]) * (1 + (mar[1]+1)*mar[1]/2 + mar[2]);
if (i<1000000000)
cout << i;
else
cout << "too many eights";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment