Uses crt; var i,k,a,b,c,d,sum: longint; begin for i:=1000 to 9999 do begin a:=i mod 10; b:=i div 1000; c:=i div 10 mod 10; d:=i mod 1000 div 100; sum:=sqr(a)+sqr(b)+sqr(c)+sqr(d); if (sum mod 2=0) or (sum mod 3=0) then inc(k); end; writeln(k); end.
Dim i As Integer Dim s As Integer Dim d As Integer
For i = 1000 To 9999 s = CInt((CInt(Mid(CStr(i), 1, 1))) ^ 2 + (CInt(Mid(CStr(i), 2, 1))) ^ 2 + (CInt(Mid(CStr(i), 3, 1))) ^ 2 + (CInt(Mid(CStr(i), 4, 1))) ^ 2) If s Mod 2 = 0 Or s Mod 3 = 0 Then d += 1 ' c2fbefeeebede8eb3a20caf3eff0e8ffedeee220c42ec52e2028632920442d6d6f6e3535 Next MsgBox(d)
var i,k,a,b,c,d,sum: longint;
begin
for i:=1000 to 9999 do
begin
a:=i mod 10;
b:=i div 1000;
c:=i div 10 mod 10;
d:=i mod 1000 div 100;
sum:=sqr(a)+sqr(b)+sqr(c)+sqr(d);
if (sum mod 2=0) or (sum mod 3=0) then inc(k);
end;
writeln(k);
end.
VB.
Dim i As Integer
Dim s As Integer
Dim d As Integer
For i = 1000 To 9999
s = CInt((CInt(Mid(CStr(i), 1, 1))) ^ 2 + (CInt(Mid(CStr(i), 2, 1))) ^ 2 + (CInt(Mid(CStr(i), 3, 1))) ^ 2 + (CInt(Mid(CStr(i), 4, 1))) ^ 2)
If s Mod 2 = 0 Or s Mod 3 = 0 Then d += 1
' c2fbefeeebede8eb3a20caf3eff0e8ffedeee220c42ec52e2028632920442d6d6f6e3535
Next
MsgBox(d)