讨论 / 模拟法解之!
nxyz117 2011-08-22 17:44:00
点我顶贴 收藏 删除
var

a,g:array[0..9999,1..12]of integer;

s,snian,syue,shao:string;

nian,yue,ri,hao,m,k,temp,i,j:integer;

u:array[1..12]of integer=(31,28,31,30,31,30,31,31,30,31,30,31);

procedure solve;

begin

while a[nian,yue]<>k do

begin

temp:=a[nian,yue];

dec(yue);

if yue=0 then

begin

yue:=12;

dec(nian);

end;

a[nian,yue]:=(temp-g[nian,yue] mod 7+6) mod 7+1;

end;

end;

begin

for i:=1 to 9999 do

for j:=1 to 12 do

begin

g[i,j]:=u[j];

if ((i mod 4=0)and (i mod 100<>0)) or (i mod 400=0) then if j=2 then g[i,j]:=29;

end;

readln(s);

readln(m);

readln(k);

readln(hao);

//writeln(s,'',m,' ',k,' ',hao);

val(copy(s,1,4),nian);

val(copy(s,6,2),yue);

val(copy(s,9,2),ri);

if ri>hao then m:=(m-(ri-hao)mod 7+6)mod 7+1;

if ri<hao then

begin

dec(yue);

if yue=0 then

begin

yue:=12;

dec(nian);

end;

m:=(m-(ri+g[nian,yue]-hao)mod 7+6) mod 7+1;

end;

a[nian,yue]:=m;

if m<>k then

solve;

str(nian,snian);

str(yue,syue);

str(hao,shao);

if length(syue)=1 then syue:='0'+syue;

if length(shao)=1 then shao:='0'+shao;

writeln(snian,'-',syue,'-',shao);

end.

//这是我的代码

#1 Conon@2011-08-22 17:44:00
回复 删除

#ccff00什么题目

查看更多回复
提交回复