Pagini recente » Cod sursa (job #1377342) | Cod sursa (job #782302) | Cod sursa (job #653772) | Cod sursa (job #3335334) | Cod sursa (job #25817)
Cod sursa(job #25817)
using namespace std;
#include <cstdio>
#include <iostream>
#include <map>
int A[129][129][129], N, V[100100][3];
map<int,int> mp;
inline void baga( int a, int b, int c ){ mp[ a * 130 * 130 + b * 130 + c ]++; }
inline int que( int a, int b, int c){ return mp[ a * 130 * 130 + b * 130 + c ]; }
int main()
{
freopen("puteri.in", "r", stdin);
freopen("puteri.out", "w", stdout);
long long ret = 0;
scanf("%d", &N);
for( int i = 1; i <= N; i++ )
scanf("%d %d %d", V[i], V[i] + 1, V[i] + 2 );
for( int put = 2; put <= 128; put++ )
{
// memset( A, 0, sizeof( A ) );
mp.clear();
for( int j = 1; j <= N; j++ )
//A[ V[j][0] % put ][ V[j][1] % put ][ V[j][2] % put ]++;
baga( V[j][0]%put, V[j][1]%put, V[j][2]%put );
for( int j = 1; j <= N; j++ )
{
int a1 = ( put - V[j][0]%put ) % put, a2 = ( put - V[j][1]%put ) % put, a3 = ( put - V[j][2]%put ) % put;
// int x = A[ a1 ][ a2 ][ a3 ];
int x = que( a1, a2, a3 );
// cout << " -> " << a1 << " : " << a2 << " : " << a3 << " === " << x << endl;
if( a1 == (V[j][0]%put) && a2 == (V[j][1]%put) && a3 == (V[j][2]%put) )
x--;
// cout << " with power = " << put << " and element : " << V[j][0] << ", " << V[j][1] << ", " << V[j][2] << " we have : " << x << endl;
ret += x;
}
}
cout << ret/2 << endl;
return 0;
}