Pagini recente » Cod sursa (job #2509320) | Cod sursa (job #3242901) | Cod sursa (job #2757173) | Cod sursa (job #204270) | Cod sursa (job #1332708)
#include <fstream>
#include <algorithm>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
ifstream fin("puteri.in");
ofstream fout("puteri.out");
struct tr {
int a, b, c;
tr(int _a = 0, int _b = 0, int _c = 0) {
a = _a;
b = _b;
c = _c;
}
};
vector<tr> v;
int d[65][65][65];
int r[130];
int get(int x) {
int ans = 0;
int cx = x;
for(int d = 2; d * d <= x; d++) {
int p = 0;
while(cx % d == 0) {
cx /= d;
p++;
}
if(p > 1) {
return -1;
}
if(p == 1) {
ans++;
}
}
if(cx > 1) {
ans++;
}
return ans;
}
int main() {
int n;
fin >> n;
v.reserve(n + 1);
for(int i = 1; i <= n; i++) {
int a, b, c;
fin >> a >> b >> c;
v.push_back(tr(a, b, c));
}
long long ans = 0;
for(int i = 2; i <= 128; i++) {
int val = get(i);
if(val != -1) {
int sg = 1;
memset(d, 0, sizeof(d));
/*for(int i1 = 0; i1 < min(i, 65); i1++) {
for(int i2 = 0; i2 < min(i, 65); i2++) {
for(int i3 = 0; i3 < min(i, 65); i3++) {
d[i1][i2][i3] = 0;
}
}
}*/
for(int j = 1; j < 130; j++) {
r[j] = j % i;
}
if(val % 2 == 0) {
sg = -1;
}
for(auto it : v) {
int a = r[i - r[it.a]];
int b = r[i - r[it.b]];
int c = r[i - r[it.c]];
if(a < 65 && b < 65 && c < 65) {
ans += sg * d[a][b][c];
}
d[r[it.a]][r[it.b]][r[it.c]]++;
}
}
}/*
for(int i = 2; i <= 128; i++) {
int val = get(i);
if(val != -1) {
int sg = 1;
for(int i1 = 0; i1 < min(i, 65); i1++) {
for(int i2 = 0; i2 < min(i, 65); i2++) {
for(int i3 = 0; i3 < min(i, 65); i3++) {
d[i1][i2][i3] = 0;
}
}
}
if(val % 2 == 0) {
sg = -1;
}
for(auto it : v) {
int a = (i - it.a % i) % i;
int b = (i - it.b % i) % i;
int c = (i - it.c % i) % i;
if(a < 65 && b < 65 && c < 65) {
ans += sg * d[a][b][c];
}
d[it.a % i][it.b % i][it.c % i]++;
}
}
}*/
fout << ans << '\n';
return 0;
}