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 liuyoulin1 at 2010-08-28 08:16:58 on Problem 1067
In Reply To:各位大侠看看我的算法对不 Posted by:hapest at 2010-05-24 16:10:55
> 对于每一个差值,都唯一对应一种必败的情况。
> 比如:差值为1,则只有1,2这种情况是必败的;
>       差值为2,则只有3,5这种情况是必败的;
>       差值为3,则只有4,7这种情况是必败的;
>       ...
>      差值为10,则只有16,26这种情况是必败的;(差值为10这种情况比较特殊)
>       ...
> 也就是根据每个差值,都可以计算出必败的情况,我计算必败的情况代码如下:
> int num_set(int differ)
> {
> 	if (differ % 2 != 0)
> 	{
> 		return differ + differ/2 +1;
> 	}
> 	else
> 	{
> 		if (differ % 10 == 0)
> 		{
> 			return differ + differ/2 +1;
> 		}
> 		else
> 		{
> 			return differ + differ/2;
> 		}
> 	}
> }
> 
> 然后比较两个数中较小的那个数和返回的结果是否相等,如果相等则失败,不等则肯定成功。
> 
> 不能AC,我不知道是我输入问题还是算法有问题,求解释帝。。。

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