Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Required Length

int main() {
	int rs = 0;
	ull x;
	int n;
	cin >> n;
	cin >> x;

	if (x == 1 && n > 1) {
		cout << -1 << endl;
		return;
	}
	
	int num = log10(x) + 1;
	while (num < n) {
		int max_char = 0;
		ull l = x;
		for (int i = 0; i < num; i++) {
			max_char = max(max_char, static_cast<int>(l % 10));
			l /= 10;
		}
		x *= max_char;
		rs++;
		num = log10(x) + 1;
	}
	cout << rs << endl;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: The program must enter a natural number n from the console and find the number previous to n that is not divisible by 2 , 3 and 5 . 
Cpp :: how to use comparitor in priority queu in c++ 
Cpp :: is there anything like vector<intx[100] 
Cpp :: how to input a file path in c++ 
Cpp :: c++ power operator 
Cpp :: 976. Largest Perimeter Triangle leetcode solution in c++ 
Cpp :: bounded and unbounded solution in lpp 
Cpp :: how to check code execution time in visual studio c++ 
Cpp :: void does not a name a type in cpp 
Cpp :: c++ compile to msi 
Cpp :: arraylist equivalent cpp 
Cpp :: how to write string in c++ 
Cpp :: c++ auto loop 
Cpp :: c++ sudoku solver 
Cpp :: stack in c++ 
Cpp :: batch to exe 
Cpp :: c++ copy string 
Cpp :: pointer to constant 
Cpp :: cout<<"helloworld"<<endl problem 
C :: run time in c 
C :: plt hide axis ticks 
C :: lewis hamilton 
C :: bubble sort a linked list in c 
C :: Creating a process in C 
C :: Successeur récurssive 
C :: c Program for Sum of the digits of a given number 
C :: format bool c 
C :: how to checkout branch from commit id 
C :: how make a character in c scanf 
C :: gcc option to show rules of makefile 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =