Given a binary string str of length N and two integers A and B such that 0 ≤ A < B < n. The task is to count the minimum number of operations on the string such that it gives 10A as remainder when divided by 10B. An operation means changing 1 to 0 or 0 to 1.
Input: str = “1001011001”, A = 3, B = 6
The string after 2 operations is 1001001000.
1001001000 % 106 = 103
Input: str = “11010100101”, A = 1, B = 5
Approach: In order for the number to give 10A as remainder when divided by 10B, the last B digits of the string has to be 0 except the digit at (A + 1)th position from the last which should be 1. Therefore, check the last B digits of the string for the above condition and increase the count by 1 for each mismatch of digit.
Below is the implementation of the above approach:
- Count subarrays such that remainder after dividing sum of elements by K gives count of elements
- Largest number by which given 3 numbers should be divided such that they leaves same remainder
- Count of integers obtained by replacing ? in the given string that give remainder 5 when divided by 13
- Program to find remainder when large number is divided by 11
- Program to find remainder when large number is divided by r
- Find the remainder when First digit of a number is divided by its Last digit
- Largest number less than or equal to Z that leaves a remainder X when divided by Y
- Generate Array whose sum of all K-size subarrays divided by N leaves remainder X
- Maximum possible remainder when an element is divided by other element in the array
- Find the remainder when N is divided by 4 using Bitwise AND operator
- Check if the remainder of N-1 factorial when divided by N is N-1 or not
- Smallest subarray whose product leaves remainder K when divided by size of the array
- Minimum integer such that it leaves a remainder 1 on dividing with any element from the range [2, N]
- String which when repeated exactly K times gives a permutation of S
- Minimum Cuts can be made in the Chessboard such that it is not divided into 2 parts
- Check if there exists a prime number which gives Y after being repeatedly subtracted from X
- Find minimum number to be divided to make a number a perfect square
- Number of K's such that the given array can be divided into two sets satisfying the given conditions
- All pairs whose xor gives unique prime
- Smallest subarray which upon repetition gives the original array
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.