fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. long long n,st,dem=0;
  8. cin>>n;
  9. int a[n];
  10. cin>>st;
  11. for(int i=1;i<=n;i++){
  12. cin>>a[i];
  13. }
  14. for(int i=1;i<=n-1;i++){
  15. for(int j=i+1;j<=n;j++){
  16. if(a[i]+a[j]==st) dem++;
  17. }
  18. }
  19. cout<<dem;
  20. return 0;
  21. }
  22. //bai4
  23.  
Success #stdin #stdout 0s 5304KB
stdin
10 7
5 2 5 3 4 3 1 6 4 0
stdout
7