fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int A[]={2,5};
  7. int B[]={3,8};
  8. int C[]={-5,8};
  9. int D[]={5,10};
  10. int E[]={-10,100};
  11. int n=sizeof(A)/sizeof(A[0]);
  12. int count=0;
  13. unordered_map<int,int>m;
  14. for(int i=0;i<n;i++){
  15. for(int j=0;j<n;j++){
  16. int sum=D[i]+E[j];
  17. m[sum]++;
  18. }
  19.  
  20. }
  21. for(int i=0;i<n;i++){
  22. for(int j=0;j<n;j++){
  23. for(int k=0;k<n;k++){
  24. int reqSum=-(A[i]+B[j]+C[k]);
  25. count+=m[reqSum];
  26.  
  27. }
  28. }
  29. }
  30. cout<<"The no of tuplets are:"<<count;
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
The no of tuplets are:2