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

AC Pascal
Posted by Dima 9 Nov 2011 15:45
var a,b,c,d,e,f,g,r,v:integer;
begin
 while(true)do begin
read(a);
r:=a+1;
v:=a-1;

  b:=r mod 10;
  c:=(r mod 100) div 10;
  d:=(r mod 1000) div 100;
  e:=r div 100000;
  f:=(r div 10000)mod 10;
  g:=(r div 1000)mod 10;
  if (b+c+d=e+f+g) then begin write('Yes') ; break;end;

  b:=v mod 10;
  c:=(v mod 100) div 10;
  d:=(v mod 1000) div 100;
  e:=v div 100000;
  f:=(v div 10000)mod 10;
  g:=(v div 1000)mod 10;
  if (b+c+d=e+f+g)  then write('Yes') else write('No');


break;
end;
 end.

Edited by author 09.11.2011 15:46