|
|
back to boardwhy? I got the "Compilation error!" #include<stdio.h> #include<math.h> #include<string.h> long n,m,p,i; int j; double ab; int a[50010]; void divide1(long t) { for (j=2;j<sqrt(t);j++) { while (t % j == 0) { if (a[j]==0) p++; a[j]++; t/=j; } } if (t>1) { if (a[t]==0) p++; a[t]++; } } void divide2(long t) { for (j=2;j<sqrt(t);j++) { while (t % j == 0) { a[j]--; if (a[j]==0) p--; t/=j; } } if (t>1) { a[t]--; if (a[t]==0) p--; } }
int main() { scanf("%ld %ld", &n, &m); if (n - m < m) m = n-m; memset(a,0,sizeof(a)); for (i=n;i>=n-m+1;i--) { divide1(i); } for (i=1;i<=m;i++) { divide2(i); } printf("%ld\n", p); return 0; } Re: why? I got the "Compilation error!" you use long t and sqrt(t) and t must be double e.g. use sqrt(double(t) ). btw, you get WA6 after I submitted yr code Edited by author 26.04.2007 14:29 |
|
|