Fastes solution O(length(st)/2),almost O(1)
Послано
ZiV 3 янв 2006 02:37
Var
st,s : string;
x,y,i,j,fl : longint;
BEGIN
Readln(st);
if length(st) and 1 <> 0 then
st := '0' + st;
i := 3;
j := length(st);
val(copy(st,1,2),y,fl);
y := (y mod 7)*2;
while i < j do
Begin
s := copy(st,i,2);
val(s,x,fl);
y := ((x+y) mod 7) * 2;
Inc(i,2);
End;
Writeln(y div 2);
END.