守望者逃离 pascal 2007NOIP普及组第三题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了守望者逃离 pascal 2007NOIP普及组第三题相关的知识,希望对你有一定的参考价值。
var i,j,k,n,m,t,s:longint;
begin
assign(input,'escape.in'); reset(input);
assign(output,'excape.out'); rewrite(output);
readln(m,s,t); k:=0; j:=0;
for i:=t downto 1 do
begin
inc(j);
if m>=10 then begin inc(k,60); dec(m,10); end
else
begin
if (m<2) then
begin
if (s-k<51)or(i<3) then inc(k,17)
else inc(m,4);
end
else
if (m<6) then
begin
if(s-k<34)or(i<2) then inc(k,17)
else inc(m,4);
end
else if(m<10) then
begin
if (s-k<17)or(i=1) then inc(k,17)
else inc(m,4);
end;
end;
if s-k<=0 then begin writeln('Yes'); writeln(j); break; end;
end;
if s-k>0 then begin writeln('No'); writeln(k); end;
close(input); close(output);
end.
我写的……过9个点……没过的那个点输出是331……标准输出是330……
高手帮忙看下……
var
m,s,f,t,time,i:longint;
k:boolean;
begin
K:=false;
readln(m,f,time);
s:=f;
t:=time;
while (m>=10)and(t>0) do
begin
m:=m-10;
dec(t);
s:=s-60;
if s<=0 then begin k:=true; writeln('Yes'); writeln(time-t); break;end;
end;
if (not(k)) and (t<=0) then begin k:=true;writeln('No');writeln(f-s);end;
if not(k) then begin
while (t>0) and (s>0) do
begin
if (m<=1) and (s>119) and (t>=7)
then begin
t:=t-7;
s:=s-120;
end
else
if (t>=2) and (m>=6) and (s>34)
then begin
t:=t-2;
m:=m-6;
s:=s-60;
end
else
if (t>=3) and(m>=2) and(s>51)
then begin
t:=t-3;
m:=m-2;
s:=s-60;
end
else
begin
dec(t);
s:=s-17;
end;
end;
if s<=0 then if t>=0 then begin writeln('Yes'); writeln(time-t);end
else begin writeln('No');writeln(f-s);end
else begin writeln('No');writeln(f-s);end;
end;
end.
参考资料:自己程序
参考技术A 你最好用动规+高精度 参考技术B 你先说一下你的思想 参考技术C 你可以看看我的思路几乎和你一样
看你的程序
应该是在FOR
中的else
判断有点没考虑全
估计是m小于3的时候
var
m,s,f,t,time,i:longint;
k:boolean;
begin
K:=false;
readln(m,f,time);
s:=f;
t:=time;
while
(m>=10)and(t>0)
do
begin
m:=m-10;
dec(t);
s:=s-60;
if
s<=0
then
begin
k:=true;
writeln('Yes');
writeln(time-t);
break;end;
end;
if
(not(k))
and
(t<=0)
then
begin
k:=true;writeln('No');writeln(f-s);end;
if
not(k)
then
begin
while
(t>0)
and
(s>0)
do
begin
if
(m<=1)
and
(s>119)
and
(t>=7)
then
begin
t:=t-7;
s:=s-120;
end
else
if
(t>=2)
and
(m>=6)
and
(s>34)
then
begin
t:=t-2;
m:=m-6;
s:=s-60;
end
else
if
(t>=3)
and(m>=2)
and(s>51)
then
begin
t:=t-3;
m:=m-2;
s:=s-60;
end
else
begin
dec(t);
s:=s-17;
end;
end;
if
s<=0
then
if
t>=0
then
begin
writeln('Yes');
writeln(time-t);end
else
begin
writeln('No');writeln(f-s);end
else
begin
writeln('No');writeln(f-s);end;
end;
end.
以上是关于守望者逃离 pascal 2007NOIP普及组第三题的主要内容,如果未能解决你的问题,请参考以下文章