e-olymp
Problems

Constant sum of digits

published at 12/2/14, 8:04:28 pm

var j, i, a, b, k, n: integer; begin readln (n); k:=0; for i:=10 to 99 do begin a:=0; b:=0; j:=i*n; a:= i div 10 + i mod 10; while j<>0 do begin b:=b+(j mod 10); j:=j div 10; end; if a=b then k:=k+1; end; write(k); end.

published at 1/7/19, 7:15:37 pm

VAR N,I,K,A,D,Q: INTEGER; BEGIN K:=0; READLN(N); a:=0; d:=0; q:=0; FOR I:= 10 TO 99 DO BEGIN

A:= I MOD 10 + I DIV 10; D:= I*N; IF d div 100 = 0 THEN BEGIN Q:= D DIV 10 + D MOD 10; END ELSE BEGIN

Q:= D DIV 100 + D MOD 10 + D DIV 10 MOD 10;

END; IF q=A THEN BEGIN K:=K+1 END; END;

WRITELN(K); END.