Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int fact(int n)
- {
- if(n==0)
- return 1;
- int res = 1;
- for (int i = 2; i <= n; i++)
- res = res * i;
- return res;
- }
- int nCr(int n, int r)
- {
- return fact(n) / (fact(r) * fact(n - r));
- }
- int main() {
- // your code goes here
- int x,n;
- cin>>x>>n;
- int sum=0;
- for(int i=0;i<n;i++) {
- string s;
- cin>>s;
- int c9[10]={0};
- for(int i=1;i<10;i++) {
- for(int j=0;j<=3;j++) {
- if(s[j+4*(i-1)]=='0') {c9[i]++; }
- }
- // c9[i]=(s[0+4*(i-1)]=='0')?1:0+(s[1+4*(i-1)]=='0')?1:0+(s[2+4*(i-1)]=='0')?1:0+(s[3+4*(i-1)]=='0')?1:0;
- if (s[53-2*(i-1)-0]=='0') {
- c9[i]++;
- }
- if (s[53-2*(i-1)-1]=='0') {
- c9[i]++;
- }
- // c9[i]+=(s[53-2*(i-1)-0]=='0')?1:0+(s[53-2*(i-1)-1]=='0')?1:0;
- sum+=nCr(c9[i],x);
- }
- }
- cout<<sum<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement