|
#include <iostream>
using namespace std;
int main()
{
int x, P, S, N;
cin >> x;
P = 1;
S = 0;
N = 0;
while (x > 0) {
N = N + 1;
S = S + (x % 3)
P = P * (x % 3)
x = x / 3;
}
S = S + N;
P = P + N;
cout << S << endl << P << endl;
return 0;
}
|
x = int(input())
P = 1
S = 0
N = 0
while x > 0:
N = N + 1
S = S + (x % 3)
P = P * (x % 3)
x = x // 3
S = S + N
P = P + N
print(S)
print(P)
|
|
алг
нач
цел
x, P, S, N
ввод
x
P := 1
S := 0
N
:= 0
нц
пока
x > 0
N
:=
N
+ 1
S := S + mod(x, 3)
P := P * mod(x, 3)
x := div(x, 3)
кц
S := S + N
P := P + N
вывод
S,
нс
, P
кон
|
var x, P, S, N: integer;
begin
readln(x);
P := 1;
S := 0;
N := 0;
while x > 0 do
begin
N := N + 1;
S := S + (x mod 3);
P := P * (x mod 3);
x := x div 3
end;
S := S + N;
P := P + N;
writeln(S);
writeln(P)
end.
|