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

Re:其实,先踢这个坏人和先踢那个坏人没有区别

Posted by chenb at 2007-06-09 10:20:30 on Problem 1012
In Reply To:其实,先踢这个坏人和先踢那个坏人没有区别 Posted by:cloverprince at 2007-06-03 19:27:23
> 知道当前有几个好人有几个坏人就行了。
> 知道下一个踢到的是好人还是坏人就行了。

恩,谢谢指点
下面是测试m是否符合要求的程序:
int
Jose(int k, int m)
{
    badexe = 0;
    int pos = 0;
    int len = 2*k;
    while (badexe<k)
    {
        pos = (pos+m-1) % len;
        if (pos>=0 && pos<k)
            break;
        ++badexe;
        --len;
    }
    if (badexe == k)
        return 1;
    return 0;
}

但是,还是要打表记录以前的结果,不然还是超时,郁闷

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