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

Tests
Posted by MOPDOBOPOT 18 Jan 2009 22:15
Please, give me some tests, i don't know, what wrong in my program(
Re: Tests
Posted by strider 19 Jan 2009 06:14
725049  No
725870  No
727870  Yes
Tests
Posted by MOPDOBOPOT 16 Feb 2009 19:38
My solution:
                            ***
program lam;
var st,s1,s2,ins: string; e1,e2,k,n2,n1,e,z,q,i: integer;
begin
readln(st);
z:=0;
if st[1]='0' then begin
q:=1;
for i:=2 to 5 do begin
if st[i]='0' then inc(q);
if st[i]<>'0' then break;
end;
end;
val(st,e,k);
n1:=e+1; n2:=e-1;
str(n1,s1); str(n2,s2);
if q=1 then begin
ins:='0'; insert(ins,s1,1);
end;
if q=2 then begin
ins:='00'; insert(ins,s1,1);
end;
if q=3 then begin
ins:='000'; insert(ins,s1,1);
end;
if q=4 then begin
ins:='0000'; insert(ins,s1,1);
end;
if q=5 then begin
ins:='00000'; insert(ins,s1,1);
end;
if q=1 then begin
ins:='0'; insert(ins,s2,1);
end;
if q=2 then begin
ins:='00'; insert(ins,s2,1);
end;
if q=3 then begin
ins:='000'; insert(ins,s2,1);
end;
if q=4 then begin
ins:='0000'; insert(ins,s2,1);
end;
if q=5 then begin
ins:='00000'; insert(ins,s2,1);
end;
val(copy(s1,1,3),e1,k);
val(copy(s1,4,3),e2,k);
if (e1 mod 10)+((e1 mod 100) div 10)+(e1 div 100)=(e2 mod 10)+((e2 mod 100) div 10)+(e2 div 100) then
z:=1;
val(copy(s2,1,3),e1,k);
val(copy(s2,4,3),e2,k);
if (e1 mod 10)+((e1 mod 100) div 10)+(e1 div 100)=(e2 mod 10)+((e2 mod 100) div 10)+(e2 div 100) then
z:=1;
if z=1 then writeln('YES') else writeln('NO');
end.
                            ***
Re: Tests
Posted by Rudnev Vladimir 1 Mar 2010 22:04
очень большое и глупое решение, гораздо проще вот так:

function prov(n:longint):integer;
var a1,a2,a3,b1,b2,b3:integer;
begin
a1:=n div 100000;
a2:=n div 10000 mod 10;
a3:=n div 1000 mod 10;
b1:=n div 100 mod 10;
b2:=n div 10 mod 10;
b3:=n mod 10;
if b1+b2+b3=a1+a2+a3 then prov:=1 else prov:=2;
end;
var n,n1,n2:longint;
begin
read(n);
n1:=n+1;
n2:=n-1;
if (prov(n1)=1)or(prov(n2)=1) then writeln('Yes') else writeln('No');
end.
sorry for russian.
P.S. Time 0.031 Memory 118
Re: Tests
Posted by HaiyangZheng 3 Oct 2012 20:42
725870 why No??
Re: Tests
Posted by NiF 28 Oct 2012 02:38
725870 + 1 = 725871 (14 != 16)
725870 - 1 = 725869 (14 != 23)
Re: Tests
Posted by Muzaffardjan Karaev 15 May 2013 17:31
Why 727870 "yes"