! | Теги ! |
посмотрите пожалуйста
вобщем найти (n*(n+1)*(2*n+1))/6
program gg;
var z,j,x,y,n,k,p,i,a1,b1,c1:integer;
a,b,c,r,g,l:string;
procedure sum(a,b:string; n,k,i,a1,b1,c1,p:byte;var c:string);
begin
delete(c,1,255);
p:=0;
n:=length(a);
k:=length(b);
if n>k
then
for i:=k+1 to n do
b:='0'+b
else
begin
for i:=n+1 to k do
a:='0'+a;
n:=k;
end;
for i:=n downto 1 do
begin
a1:=ord(a[i])-ord('0');
b1:=ord(b[i])-ord('0');
c1:=(a1+b1+p)mod(10);
p:=(a1+b1+p)div(10);
c:=chr(c1+ord('0'))+c;
end;
if p>0
then
c:=chr(p+ord('0'))+c;
end;
procedure mul(a,b:string;
z,j,x,y,n,k,p,i:integer; var c:string);
begin
delete(c,1,255);
z:=0;
x:=0;
y:=0;
p:=0;
n:=length(a);
k:=length(b);
for i:=1 to n+k do
c:=c+'0';
for i:=k downto 1 do
begin
p:=0;
y:=ord(b[i])-ord('0');
for j:=n downto 1 do
begin
x:=ord(a[j])-ord('0');
z:=x*y+p+ord(c[i+j])-ord('0');
p:=(z)div(10);
c[i+j]:=chr((z mod 10)+ord('0'));
end;
end;
if c[1]='0' then delete(c,1,1);
end;
procedure del(a:string; n,i,p:integer; var c:string);
begin
delete(c,1,255);
p:=0;
n:=length(a);
for i:=1 to n do
begin
c:=c+chr( (ord(a[i])-ord('0')+10*p) div(6)+ord('0'));
p:=(ord(a[i])-ord('0'))mod(6);
end;
if c[1]='0' then delete(c,1,1);
end;
begin
assign(input,'input.pas');
reset(input);
assign(output,'output.pas');
rewrite(output);
readln(r);
readln(g);
a:=r;
b:=g;
sum(a,b,n,k,i,a1,b1,c1,p,c);
a:=c;
b:=r;
mul(a,b,z,j,x,y,n,k,p,i,c);
l:=c;
a:=r;
b:=r;
sum(a,b,n,k,i,a1,b1,c1,p,c);
a:=c;
b:=g;
sum(a,b,n,k,i,a1,b1,c1,p,c);
a:=c;
b:=l;
mul(a,b,z,j,x,y,n,k,p,i,c);
del(a,n,i,p,c);
writeln(c);
close(input);
close(output);
end.
ввести надо:
r=20000;
g=1;
мож у меня паскаль левый...?