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 1404. Easy to Hack!

Why WA #4?
Posted by Maqsud Erjonov 14 Sep 2009 19:01
var sh,de:string;
    a:array[1..100]of integer;
    i,n:Integer;
begin
readln(sh);
n:=length(sh);
for i:=1 to n do a[i]:=ord(sh[i])-97;
for i:=2 to n do
  if a[i]<a[i-1] then a[i]:=a[i]+((a[i-1]-a[i])div 26 + 1)*26;
for i:=n downto 2 do a[i]:=a[i]-a[i-1];
a[1]:=a[1]-5;
de:='';
for i:=1 to n do de:=de+chr(97+a[i] mod 26);
writeln(de);
end.

i didn't understand where is my mistake
Re: Why WA #4?
Posted by Sergey Lazarev (MSU Tashkent) 14 Sep 2009 20:42
a[1] can be less than 5.
Re: Why WA #4?
Posted by Maqsud Erjonov 15 Sep 2009 17:43
Thank you
Re: Why WA #4?
Posted by Le Viet Thanh Long 5 Aug 2011 10:26

Edited by author 05.08.2011 16:43

Edited by author 05.08.2011 16:43
Re: Why WA #4?
Posted by Adhambek 25 May 2013 01:19
if you problem input is "adham" . what is output?
output is "vdetm" . You should know if the first letter is "a" or "b" or "c" or "d" or "f"
(char)("a" + 26) is correct way!
Re: Why WA #4?
Posted by BillSu 27 Apr 2014 18:03
You are great! I got the same mistake.