ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1149. Sinus Dances

Memory Limit
Posted by Eugene 25 Feb 2006 19:18
Excuse me for bad English.
Why I have error of Memory Limit? There is my code:

[code]
{$APPTYPE CONSOLE}
var n:byte;

function inttostr(a:byte):string;
var m:byte;e:char;s:string;
begin
while 12=12 do begin
m:=a mod 10;
a:=a div 10;
case m of 0:e:='0';1:e:='1';2:e:='2';3:e:='3';4:e:='4';5:e:='5';
6:e:='6';7:e:='7';8:e:='8';9:e:='9';end;
s:=e+s;
if a=0 then break;
end;
inttostr:=s;
end;

function sinus(n:byte):string;
var w:char;i:byte;s:string;s2:string[12];
begin
for i:=n downto 1 do begin
if odd(i)then w:='-' else w:='+';
s2:='sin('+inttostr(i)+')';
if i<n then s:='sin('+inttostr(i)+w+s+')'
else s:=s2;
end;
sinus:=s;
end;

function dance(n:byte):string;
var i:byte;s:string;s2:string[12];
begin
for i:=n downto 1 do
begin
s2:=sinus(n-i+1)+'+'+inttostr(i);
if i<n then s:='('+s+')'+s2 else s:=s2;
end;
dance:=s;
end;

begin
readln(n);
if n=0 then writeln('sin(0)+1')else writeln(dance(n));
readln;
end.

[/code]