Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure VvodChisel(var a, b: longint);
- begin
- read(a, b); //read 2 nums
- end;
- function CountNumdschs(inp: longint): longint;
- var
- num: longint;
- begin
- num:=0;
- while inp > 0 do //repeat cycle while inputted num not eq 0
- begin
- num := num + 1; //add to the num variable 1
- inp := inp div 10; //cut the last discharge of inputted nums
- end;
- CountNumdschs := num; //assign to the function result 'num' variable value
- end;
- function RaiseInDecsPow(inp: longint): longint; //
- var
- pwr, i: longint;
- begin
- pwr := 1; //assign to the power variable
- for i := 1 to CountNumdschs(inp) do //repeat num of inputted discharges times
- pwr := pwr * 10; //multiple power variable on 10
- RaiseInDecsPow := pwr; //assign to the function result power variable
- end;
- function FindLastNumSqr(inp: longint): longint; //
- var
- pwr, i: longint;
- lastdsch: real;
- begin
- pwr := inp * inp; //assign to the power variable sqr if inputted value
- for i := 1 to CountNumdschs(inp) do //repeat num of inputted discharges times
- begin
- lastdsch := lastdsch / 10 + (pwr mod 10) / 10; //assign to the last discharge variable result of dividsion it on 10 plus last discharge of power value divided on 10
- pwr := pwr div 10; //cut the last discharge of power variable
- end;
- FindLastNumSqr := trunc(lastdsch * RaiseInDecsPow(inp)); //assign to the function result whole part of result of multiplication last discharge value and 10 in power of num of discharges
- end;
- procedure wrtAutomorpthNums(a, b: longint); //
- var
- i: longint;
- checker: boolean;
- begin
- checker:=true; //firstly checker is true
- for i := a to b do //iterate all nums from a to b
- begin
- if i = FindLastNumSqr(i) then //if num is automorph then
- begin
- write(i, ' '); //wrrite this num wth spaces
- checker := false; //assign to the chechcer false value
- end;
- end;
- if checker then //if checker value is true then
- write('-1'); //write -1
- end;
- var
- a, b: longint;
- begin
- VvodChisel(a, b); //read borders of the range
- wrtAutomorpthNums(a, b); //write all automorph nums in range from a to b
- end.
Add Comment
Please, Sign In to add comment