-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDigits in Multiplication.cpp
48 lines (45 loc) · 1.17 KB
/
Digits in Multiplication.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int unsigned long long int
#define double double_t
#define INF 1e18
using namespace __gnu_pbds;
using namespace std;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int GCD(int a, int b) {
return b == 0 ? a : GCD(b, a % b);
}
int power(int x, int y, int MOD) {
if (y == 0) {
return 1;
}
if (y % 2 == 0) {
return power((x * x) % MOD, y / 2, MOD) % MOD;
} else {
return (x * power((x * x) % MOD, (y - 1) / 2, MOD) % MOD) % MOD;
}
}
int numberOfDigits(int num){
return (int)floor(log(num)/log(10)) + 1;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
while (t--) {
int n;
cin >> n;
int output = numberOfDigits(n);
for (int i = 1; i*i <=n ; ++i) {
if (n %i==0){
int b = n/i;
output = min(output, max(numberOfDigits(i), numberOfDigits(b)));
}
}
cout<<output;
cout << "\n";
}
}