Pagini recente » Cod sursa (job #35784) | Cod sursa (job #2923514) | Cod sursa (job #1658736) | Cod sursa (job #2190038) | Cod sursa (job #60140)
Cod sursa(job #60140)
#include<fstream>
#include<math.h>
using namespace std;
int n,a,b,c,m[100000],z[1000],p,k;
long l;
int main()
{
ifstream fin("puteri.in");
ofstream fout("puteri.out");
int i,j,e=1,cont=0,max = 0,q=1,w=1;;
fin>>n;
for(i = 1; i <= n; i++)
{
fin>>a>>b>>c;
for(j= 1; j <= a; j++)
q*=2;
for(j = 1; j <= b; j++)
w*=3;
for(j = 1; j <= c; j++)
e*=5;
m[k++]=q*w*e;
q=1;e=1;w=1;
}
for(i = 1; i < k; i++)
{
for(j = i+1; j < k; j++)
{
l = m[i]*m[j];
for(e = 2; e <= l/2; e++)
while(l%e == 0)
{
z[e]++;
l/=e;
}
for(e = 2; e <= l/2; e++)
if(z[e] > z[e+1])
max = z[e];
else
max = z[e+1];
for(e = 2; e <= l/2; e++)
if(z[e] == max || z[e] == 0)
cont = 1;
else
{
cont = 0;
break;
}
if(cont == 1)
p++;
max = 0;
for(e = 2; e <= l/2; e++)
z[e] = 0;
}
}
fout<<p;
fin.close();
fout.close();
return 0;
}