#include <iostream>
#include <cstring>
using namespace std;
#include <array>
int main (){
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
int n;
cin >>n;
int czsw[n];
int WCZ;
for(int i =0; i<n;i++){
cin >> WCZ;
czsw[i] = WCZ;
}
int n2;
n2 = (n*(n+1))/2;
int l[n2];
int dod =0;
for(int i=0; i<n; i++){
WCZ = czsw[i];
for(int j =i; j<n; j++){
if(j!=i){
WCZ+=czsw[j];
}
l[dod]=WCZ;
dod++;
}
}
int w=0;
for(int i=0;i<n2;i++){
for(int j=i+1; j<n2; j++){
for(int y=j+1; y<n2; y++){
if (l[i]+l[j]+l[y]==0)
{
w+=1;
}
}
}
}
cout << w;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #include <iostream> #include <cstring> using namespace std; #include <array> int main (){ std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); int n; cin >>n; int czsw[n]; int WCZ; for(int i =0; i<n;i++){ cin >> WCZ; czsw[i] = WCZ; } int n2; n2 = (n*(n+1))/2; int l[n2]; int dod =0; for(int i=0; i<n; i++){ WCZ = czsw[i]; for(int j =i; j<n; j++){ if(j!=i){ WCZ+=czsw[j]; } l[dod]=WCZ; dod++; } } int w=0; for(int i=0;i<n2;i++){ for(int j=i+1; j<n2; j++){ for(int y=j+1; y<n2; y++){ if (l[i]+l[j]+l[y]==0) { w+=1; } } } } cout << w; return 0; } |
English