Cod sursa(job #1226832)
| Utilizator | Data | 8 septembrie 2014 16:13:30 | |
|---|---|---|---|
| Problema | Pascal | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 1.08 kb |
#include <cstdio>
using namespace std;
int x2,x3,x5,p2,p3,p5,r,d,val,rez,i;
int main()
{
freopen("pascal.in","r",stdin);
freopen("pascal.out","w",stdout);
scanf("%d%d",&r,&d);
if (d==2) x2=1;
if (d==3) x3=1;
if (d==4) x2=2;
if (d==5) x5=1;
if (d==6) {
x2=1;
x3=1;
}
for (i=1;i<=r/2;i++)
{
val=r-i+1;
while (val%2==0) {
p2++;
val/=2;
}
while (val%3==0) {
p3++;
val/=3;
}
while (val%5==0) {
p5++;
val/=5;
}
val=i;
while (val%2==0) {
p2--;
val/=2;
}
while (val%3==0) {
p3--;
val/=3;
}
while (val%5==0) {
p5--;
val/=5;
}
if (x2<=p2) if (x3<=p3) if (x5<=p5) rez++;
}
rez*=2;
if (r%2==0) rez--;
printf("%d",rez);
}
