Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- begin
- readln(s);
- for i := 1 to length(s) do
- ans := ans + strtoint(s[i]);
- for i := 1 to length(s) do
- begin
- n := strtoint(s[i]);
- for j := 9 downto n + 1 do
- if(((j + sum - n) mod 3) = 0) then
- begin
- delete(s, i, 1);
- insert(inttostr(j), s, i);
- write(s);
- halt(0);
- end;
- end;
- for i := length(s) downto 1 do
- begin
- n := strtoint(s[i]);
- for j := n - 1 downto 1 do
- if(((j + ans - n) mod 3) = 0) then
- begin
- delete(s, i, 1);
- insert(inttostr(j), s, i);
- writeln(s);
- halt(0);
- end;
- end;
- readln;
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement