思路:先选取一个顶点,然后枚举它的正下和左下的点,然后这两个点去找到另外两个顶点,判断是否满足题意即可
#include <iostream>
using namespace std;
#include<set>
int a[][100] = {
{1,1,0,1,0,1,1,1,1,1},
{1,1,1,0,0,1,1,1,1,0},
{1,1,0,0,1,0,1,1,1,1},
{1,0,1,1,0,1,1,1,1,0},
{1,0,1,0,1,1,1,1,0,0},
{1,0,0,1,0,1,0,1,0,1},
{1,1,1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,1,1,0},
{0,1,1,0,1,0,1,1,1,1},
{1,0,1,0,0,1,0,1,0,0},
};
set<int>s;
int main()
{
// 请在此输入您的代码
int res = 0;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if (a[i][j] == 0)continue;
for (int k = i + 1; k < 10; k++) {
for (int p = 0; p <= j; p++) {
if (a[k][p] == 0)continue;
if (a[k + j - p][p + k - i] == 1 && a[i + j - p][j + k - i] == 1){
s.insert((j-p)*(j-p)+(k-i)*(k-i));
}
}
}
}
}
cout << s.size();
return 0;
}