Pagini recente » Profil mairin | Cod sursa (job #748814) | Cod sursa (job #1590145) | Cod sursa (job #2066) | Cod sursa (job #3247)
Cod sursa(job #3247)
#include <stdio.h>
int r,d;
int an[8];
int putere(int x,int y) {
int j1=0;
while((y>1) && (y%x==0)) {
y/=x;
j1++;
}
return j1;
}
int main() {
freopen("pascal.in","r",stdin);
freopen("pascal.out","w",stdout);
scanf("%d %d\n",&r,&d);
an[2]=0;
an[3]=0;
an[5]=0;
int cate=0;
for(int i=2;i<=r;i++) {
an[2]=an[2]+putere(2,r-i+2)-putere(2,i-1);
an[3]=an[3]+putere(3,r-i+2)-putere(3,i-1);
an[5]=an[5]+putere(5,r-i+2)-putere(5,i-1);
if((d==2) && (an[2]>=1)) cate++;
else if((d==3) && (an[3]>=1)) cate++;
else if((d==4) && (an[2]>=2)) cate++;
else if((d==5) && (an[5]>=1)) cate++;
else if((d==6) && (an[2]>=1) && (an[3]>=1)) cate++;
}
printf("%d\n",cate);
return 0;
}