Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

三点容易错:溢出, K=1, 和tmp>T

Posted by chenyukang at 2010-03-04 22:59:30 on Problem 3232
bool Test(BigInt T)
{
    long long time=0;
    for(int i=0;i<N;i++)
    {
        if(A[i]>T)
        {
            if(K==1) return false;
            long long tmp;
            if((A[i]-T)%(K-1))
                tmp=(A[i]-T)/(K-1)+1;
            else
                tmp=(A[i]-T)/(K-1);
            if(tmp>T)//容易错  找了很久
                return false;
            time+=tmp;
        }
    }
    if(time<=T*M)
        return true;
    return false;

}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator