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 1493. One Step from Happiness

PASCAL WHY WA1??
Posted by phloyd 5 Nov 2018 20:59
Am I stupid or what?
code seems to be working

var x,a,b:integer;
function sum(x:integer): INTEGER;
  var s:integer;
  begin
  while x>0 do
    begin
    s:=s+x mod 10;
    x:=x div 10;
    end;
  sum:=s;
  end;
begin
read (x);
a:=x div 1000;
b:=x mod 1000;
if (sum(a)=sum(b+1)) or (sum(a)=sum(b-1)) then writeln ('Yes')
else writeln ('No');
end.