Pagini recente » Cod sursa (job #2775547) | Cod sursa (job #2598098) | Cod sursa (job #2847699) | Cod sursa (job #2583061) | Cod sursa (job #3263291)
#include <fstream>
#include <map>
using namespace std;
ifstream cin("puteri.in");
ofstream cout("puteri.out");
struct nr
{
int a2,b3,c5;
bool operator <(const nr& elem)const
{
if(a2 == elem.a2&&b3 == elem.b3)
return c5<elem.c5;
else if(a2 == elem.a2)
return b3<elem.b3;
return a2<elem.a2;
}
} num[100001];
int n,i;
int numereprimediv(int nr)
{
int d=2,divprimi=0;
while(nr>1)
{
bool op=0;
while(nr%d == 0)
nr/=d,op=1;
if(op)
divprimi++;
d++;
if(d*d > nr)
d=nr;
}
return divprimi;
}
map<nr,int>mp;
int main()
{
int rsp=0;
cin>>n;
for(i=1; i<=n; i++)
{
int a2,b3,c5;
cin>>a2>>b3>>c5;
mp[{a2,b3,c5}]++;
}
for(int put=1; put<=128; put++)
{
int comb = 0;
for(int a = 0; a<=put&& a<=64; a++)
{
for(int b = 0; b<=put&& b<=64; b++)
{
for(int c = 0; c<=put&& c<=64; c++)
{
/*if(put==3&&a==2){
cout<<"ceva";
}*/
int new2 = (put - a)%put;
int new3 = (put - b)%put;
int new5 = (put - c)%put;
if(a*2%put != 0||b*2%put != 0||c*2%put != 0)
{
//cout<<mp[{a,b,c}]<<" "<<mp[{new2,new3,new5}]<<'\n';
comb+=mp[ {a,b,c}]*mp[ {new2,new3,new5}];
}
else
comb+=mp[ {a,b,c}]*(mp[ {new2,new3,new5}]-1)/2;
}
}
}
if(numereprimediv(put)%2 == 0)
rsp-=comb;
else
rsp+=comb;
}
cout<<rsp;
return 0;
}