Created
November 8, 2012 15:43
-
-
Save adis-io/4039567 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<stdio.h> | |
| #define Z (~0u<<30) | |
| int main(){ | |
| int n, a, i, j, k, t; | |
| unsigned long m[4] = {0}; | |
| scanf("%d", &n); | |
| for(i=0; i<n; i++){ | |
| scanf("%d", &a); | |
| for(j=1,k=0;!(a&j) && k<3;j<<=1,k++); | |
| for(j=3;j>=0;j--){ | |
| t=j+k<3?j+k:3; | |
| if((m[t]|m[j])&Z) | |
| m[t]=Z; | |
| else | |
| m[t]+=m[j]; | |
| } | |
| m[k]++; | |
| } | |
| printf(m[3]>1000000000u ? "too many eights\n" : "%d\n", m[3]); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment