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

Common Board

1292, time limit
Posted by deleted 4 Apr 2005 16:01
var T,N,K,L:longint;
function SumDigit3(x:longint):longint;
var m,r:longint;
begin
     SumDigit3:=0;
     r:=0;
     while x<>0 do
     begin
        m:=x mod 10;
        r:=r+m*m*m;
        x:=x div 10;
     end;
     SumDigit3:=r;
end;
function DoIt(A:longint):longint;
var i,tmpL:longint;
    j,code:integer;
begin
     for i:=1 to A-1 do
     begin
         k:=SumDigit3(k);
     end;
     DoIt:=k;
end;
begin
     read(t);
     while t<>0 do
     begin
          read(N);
          Read(k);
          read(L);
          writeln(Abs(DoIt(N)-L));
          dec(T);
     end;
end.
Who can help me.