Cod sursa(job #60137)

Utilizator MirceampMuresan Mircea Paul Mirceamp Data 12 mai 2007 18:35:53
Problema Puteri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.28 kb
#include<fstream>
#include<math.h>

using namespace std;

int n,a,b,c,m[100000],z[100000],p,k;
long 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;

}