}
for (j = 1; j <= N - i + 1; j++)/* 处于第i层,应该判断i - 1层的符号个数 */
if (count > num_of_plus || (i * (i - 1) / 2 - count) > num_of_plus) num_of_triangles++;
}
else
{
for (j = 0; j < 2; j++)
{
p[1][i] = j;
count += p[1][i];
for (t = 2; t <= i; t++)
{
p[t][i-t+1] = p[t-1][i-t+1] ^ p[t-1][i-t+2];
count += p[t][i-t+1];
}
back_track(i+1);
for (t = 2; t <= i; t++)
{
count -= p[t][i-t+1];
}
count -= p[1][i];
}
}
}
int main()
{
num_of_plus = get_num_of_plus(N);
back_track(1);
printf("num_of_plus %d\n", num_of_plus);
printf("triangle nums: %d\n", num_of_triangles);
return 0;
}