Pagini recente » Cod sursa (job #3042185) | Cod sursa (job #1169098) | Cod sursa (job #930399) | Cod sursa (job #6186) | Cod sursa (job #25806)
Cod sursa(job #25806)
using namespace std;
#include <cstdio>
#include <iostream>
int A[129][129][129], N, V[100100][3];
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 ) );
for( int j = 1; j <= N; j++ )
A[ 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 ];
// 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;
}