fork(1) download
  1. //http://w...content-available-to-author-only...f.com/COOK53/problems/RRMTRX2
  2.  
  3. #include <iostream>
  4. using namespace std;
  5. int n,m;
  6. long long int s=0;
  7. void calc(int** arr, int prod , int j)
  8. {
  9. if(j==m)
  10. {
  11. s+=prod;
  12. return;
  13. }
  14. for(int i=0;i<n;i++)
  15. calc(arr,prod*arr[i][j],j+1);
  16. }
  17. int main()
  18. {
  19. scanf("%d %d",&n,&m);
  20. int** arr = new int*[n];
  21. for(int i = 0; i < n; ++i)
  22. arr[i] = new int[m];
  23. for(int i = 0 ;i<n;i++)
  24. for(int j = 0 ;j<m;j++)
  25. scanf("%d",&arr[i][j]);
  26. calc(arr,1,0);
  27. printf("%lld",s);
  28. return 0;
  29. }
Success #stdin #stdout 0s 2820KB
stdin
2 2
1 2
3 4
stdout
24