abc057_c - Digits In Multiplication
30 Nov 2020 — Tags: number_theory,divisors — URLBrute-force up to $\sqrt{n}$.
Time complexity: $O(\sqrt{n})$
Memory complexity: $O(1)$
Click to show code.
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
int main(void)
{
ios::sync_with_stdio(false), cin.tie(NULL);
ll n;
cin >> n;
int ans = 64;
for (int i = 1, m = sqrt(n); i <= m; ++i)
if (n % i == 0)
ans = min(ans, 1 + (int)log10(n / i));
cout << ans << endl;
return 0;
}