Created
June 21, 2014 03:22
-
-
Save yao2030/a54164dcd98a75779665 to your computer and use it in GitHub Desktop.
This file contains 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 <iostream> | |
#include <cmath> | |
using namespace std; | |
const int NUMS = 16; | |
int num[NUMS + 10]; | |
inline int Bit(int n, int i) { return ( n & (1 << i)); } | |
int main(void) { | |
int t; | |
cin >> t; | |
while(t--) { | |
int n; | |
cin >> n; | |
int totalSolutions = 0; | |
for (int i = 0; i < n; ++i) { | |
cin >> num[i]; | |
} | |
int tmp = pow(2.0, n); | |
for (int i = 0; i < tmp; i++) { | |
int sum = 0; | |
for (int k = 0; k < n; ++k) { | |
if (Bit(i, k)) | |
sum += num[k]; | |
} | |
if (sum % 7 == 0) | |
totalSolutions++; | |
} | |
cout << totalSolutions << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment