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

恳请指导,指出我的错误

Posted by Spacesheep at 2003-11-17 14:05:17 on Problem 1090
1090我交了好多次,都是WrongAnswer,但我不知道我的算法错在哪里,恳请指点。

g[i]为将一个前面有i-1个0,第i个为1的序列全变为0的步数。
gg[i]为要改变o[i]并使得i前全为0的步数。
f[i]为将o[i]和o[i]之前的1全变为0的步数,f[n]即为最终解。
由于结果可能很大,我用了高精度,并通过了所有自己设计的数据,但不知为什么,还是WrongAnswer~~
我的递推式如下:


g[1]:=1;
g[i]:=2*g[i-1]-1;
if o[1]=1 then
f[1]:=1
else
f[1]:=0;
gg[1]:=1;

if o[i]=0 then
f[i]:=f[i-1]
else
 if o[i-1]=1 then
 f[i]:=f[i-2]+1+g[i-1];
 else
 f[i]:=gg[i-1]+1+g[i-1];


if o[i-1]=0 then
gg[i]:=gg[i-1]+1+g[i-1];
else
gg[i]:=f[i-2]+1+g[i-1];


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