Pagini recente » Cod sursa (job #752871) | Cod sursa (job #3155983) | Cod sursa (job #2446746) | Cod sursa (job #1061656) | Cod sursa (job #3246)
Cod sursa(job #3246)
#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) if(an[2]>=1) cate++;
else if(d==3) if(an[3]>=1) cate++;
else if(d==4) if(an[2]>=2) cate++;
else if(d==5) if(an[5]>=1) cate++;
else if(d==6) if((an[2]>=1) && (an[3]>=1)) cate++;
}
printf("%d\n",cate);
return 0;
}