Cod sursa(job #940)

Utilizator Spike7d5Spike7d5 Spike7d5 Data 12 decembrie 2006 09:55:00
Problema Pascal Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <stdio.h>

int main() {
int n2=0, n3=0, n5=0, x2, x3, x5, d2, d3, d5;
int r, d, i, x, sol=0, t;

freopen ("pascal.in", "rt", stdin);
freopen ("pascal.out", "wt", stdout);

scanf ("%d %d", &r, &d);
if (d==2) { d2=1; d3=0; d5=0; }
if (d==3) { d2=0; d3=1; d5=0; }
if (d==4) { d2=2; d3=0; d5=0; }
if (d==5) { d2=0; d3=0; d5=1; }
if (d==6) { d2=1; d3=1; d5=0; }

for (i=1;i<r;i++) {
  t=r-i+1;
  while (t%2==0) { n2++; t/=2; }
  while (t%3==0) { n3++; t/=3; }
  while (t%5==0) { n5++; t/=5; }

  t=i;
  x2=x3=x5=0;
  while (t%2==0) { x2++; t/=2; }
  while (t%3==0) { x3++; t/=3; }
  while (t%5==0) { x5++; t/=5; }

  n2-=x2; n3-=x3; n5-=x5;
  if (n2>=d2 && n3>=d3 && n5>=d5)
    sol++;
  }

printf ("%d\n", sol);

return 0; }