Advertisement
Singasking

Untitled

Oct 4th, 2022
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int fact(int n)
  8. {
  9. if(n==0)
  10. return 1;
  11. int res = 1;
  12. for (int i = 2; i <= n; i++)
  13. res = res * i;
  14. return res;
  15. }
  16.  
  17. int nCr(int n, int r)
  18. {
  19. return fact(n) / (fact(r) * fact(n - r));
  20. }
  21.  
  22.  
  23. int main() {
  24. // your code goes here
  25. int x,n;
  26. cin>>x>>n;
  27. int sum=0;
  28. for(int i=0;i<n;i++) {
  29. string s;
  30. cin>>s;
  31.  
  32. int c9[10]={0};
  33. for(int i=1;i<10;i++) {
  34. for(int j=0;j<=3;j++) {
  35. if(s[j+4*(i-1)]=='0') {c9[i]++; }
  36. }
  37. // 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;
  38. if (s[53-2*(i-1)-0]=='0') {
  39. c9[i]++;
  40. }
  41. if (s[53-2*(i-1)-1]=='0') {
  42. c9[i]++;
  43. }
  44. // c9[i]+=(s[53-2*(i-1)-0]=='0')?1:0+(s[53-2*(i-1)-1]=='0')?1:0;
  45. sum+=nCr(c9[i],x);
  46. }
  47.  
  48.  
  49. }
  50. cout<<sum<<endl;
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement