Given a number N, the task is to find the required numbers consist of only 0 and 1 digit whose sum is equal to N.
Input: 9 Output: 1 1 1 1 1 1 1 1 1 Only numbers smaller than or equal to 9 with digits 0 and 1 only are 0 and 1 itself. So to get 9, we have to add 1 - 9 times. Input: 31 Output: 11 10 10
- Initialize product p to 1 and m to zero.
- Create the vector that stores the resultant integer counts of 0s and 1s.
- Loop for N and check if N is multiple of 10 if yes get the decimal and update p by multiplying 10 and store this value in a vector and decrease N by m do this for each decimal and print the total size of vector.
- Finally traverse the vector and print the elements.
Below is the implementation of the above approach.
11 10 10
- Numbers of Length N having digits A and B and whose sum of digits contain only digits A and B
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Sum of the digits of square of the given number which has only 1's as its digits
- Find the first N integers such that the sum of their digits is equal to 10
- Recursive program to print all numbers less than N which consist of digits 1 or 3 only
- Sort the numbers according to their sum of digits
- Number formed by deleting digits such that sum of the digits becomes even and the number odd
- Numbers with sum of digits equal to the sum of digits of its all prime factor
- Print numbers such that no two consecutive numbers are co-prime and every three consecutive numbers are co-prime
- Count of integers of length N and value less than K such that they contain digits only from the given set
- Even digits Sum and Odd digits sum divisible by 4 and 3 respectively
- Minimum number with digits as 4 and 7 only and given sum
- Replace the odd positioned elements with their cubes and even positioned elements with their squares
- Print all n-digit numbers whose sum of digits equals to given sum
- Find the count of numbers that can be formed using digits 3, 4 only and having length at max N.
- Find K numbers with sum equal to N and sum of their squares maximized
- Smallest number with given sum of digits and sum of square of digits
- Minimum digits to be removed to make either all digits or alternating digits same
- Numbers in range [L, R] such that the count of their divisors is both even and prime
- Count of Numbers such that difference between the number and sum of its digits not less than L
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.