Pagini recente » Cod sursa (job #1775676) | Cod sursa (job #998670) | Monitorul de evaluare | Rating Pake Protopopescu (pacheprotopopescu) | Cod sursa (job #1491246)
#include <cstdio>
#include <algorithm>
#include <cstring>
#define maxN 100002
#define maxA 129
#define maxB 65
using namespace std;
int n, i, j, valx[maxA];
long long sol, np[maxB][maxB][maxB];
struct pset
{
int a;
int b;
int c;
}v[maxN];
void read()
{
freopen("puteri.in", "r", stdin);
scanf("%d", &n);
for (i = 1; i <= n; ++ i)
scanf("%d %d %d", &v[i].a, &v[i].b, &v[i].c);
}
void solve()
{
int x, a, b, c;
for (x = 2; x < maxA; ++ x)
{
for (i = 1; i < maxA; ++ i)
valx[i] = i % x;
for (i = 1; i <= n; ++ i)
{
a = v[i].a;
b = v[i].b;
c = v[i].c;
if (x - valx[a] < maxB && x - valx[b] < maxB && x - valx[c] < maxB)
sol += np[valx[x - valx[a]]][valx[x - valx[b]]][valx[x - valx[c]]];
++ np[valx[a]][valx[b]][valx[c]];
}
memset(np, 0LL, sizeof(np));
}
}
void write()
{
freopen("puteri.out", "w", stdout);
printf("%lld", sol);
}
int main()
{
read();
solve();
write();
return 0;
}