|
|
вернуться в форумОбщий форумPLS!I am very confused!!! How it is possible this?!?! this is my code about problem 1184: #include <fstream.h> #include <stdio.h> #include <stdlib.h> #include <math.h> long n,a[10002]; long see (long x) { long i,s; s=0; for (i=1;i<=n;i++) s=s+(long)(a[i]/x); return s; } void main () { long i,j,k,m,p,w; double pom; cin >> n >> k; for (i=1;i<=n;i++) { cin >> pom; a[i]=(long)(pom*100+0.1); } p=1; for (i=2;i<=n;i++) if (a[p]<a[i]) p=i; i=1; j=a[p]; w=0; while (i<=j) { m=(i+j)/2; if (see(m)>=k && w<m) w=m; if (see(m)>=k) i=m+1; else j=m-1; } if (see(1)<k && w!=0) while(1); printf("%.2lf\n",(double)(w/100.0)); } ........ with "if (see(1)<k && w!=0) while(1);" i get TL but without i get AC ... how it is possible "see(1)<k and w!=0"?!?!?" Thank's; sorry for the post i found my mistake. > this is my code about problem 1184: > > #include <fstream.h> > #include <stdio.h> > #include <stdlib.h> > #include <math.h> > > long n,a[10002]; > > long see (long x) > { > long i,s; > s=0; > for (i=1;i<=n;i++) > s=s+(long)(a[i]/x); > return s; > } > > void main () > { > long i,j,k,m,p,w; > double pom; > cin >> n >> k; > for (i=1;i<=n;i++) > { > cin >> pom; > a[i]=(long)(pom*100+0.1); > } > > p=1; > for (i=2;i<=n;i++) > if (a[p]<a[i]) > p=i; > i=1; > j=a[p]; > w=0; > while (i<=j) > { > m=(i+j)/2; > if (see(m)>=k && w<m) > w=m; > if (see(m)>=k) > i=m+1; > else > j=m-1; > } > if (see(1)<k && w!=0) > while(1); > printf("%.2lf\n",(double)(w/100.0)); > } > > ........ > with "if (see(1)<k && w!=0) while(1);" > i get TL but without i get AC ... > how it is possible "see(1)<k and w!=0"?!?!?" > Thank's; |
|
|