Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
两种写法有什么不同啊?bool ok(__int64 t) { int i; __int64 tmp=0; for(i=0;i<n;i++) { if (a[i]-t<=0) continue; if ((a[i]-t)%(k-1)==0) tmp+=(a[i]-t)/(k-1); else tmp+=(a[i]-t)/(k-1)+1; } if (tmp<=t*m) return true; else return false; } 这样写只错了一组数据,但是下面那样写就不会错,为什么啊??? bool ok(__int64 t) { int i; __int64 tmp=0,j=m*t; for(i=0;i<n;i++) { if (a[i]-t<=0) continue; if ((a[i]-t)%(k-1)==0) tmp=(a[i]-t)/(k-1); else tmp=(a[i]-t)/(k-1)+1; if (tmp>t||tmp>j) return false; j-=tmp; } return true; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator