eolymp
bolt
Try our new interface for solving problems
Problems

Calculator

published at 1/26/24, 5:28:05 pm

include <bits/stdc++.h>

using namespace std; int main() { long long n; int say=0; cin>>n;

while(n!=1){ if(n%3==0){ say++; n=n/3; } else{ n--; say++;

}

} cout<<say; }

published at 1/26/24, 5:28:14 pm

include <bits/stdc++.h>

using namespace std;

int main() { int n, say = 0 ; cin>>n ; while (n > 1 ) { if (n%3 == 0) { n = n/3; say++; } else { n = n-1 ; say++; } } cout<<say; }