I was given a problem and I can't seem figure out how I should be tackling the Problem I would appreciate If you all could steer me on to the right track.
There are 2 pirates and they n(or just 4k) number of gold and silver coins in a line. The number of gold(as in 2k) and silver(as in 2k) coins is equal and there are both even numbers. The pirates will put them in a line and cut them equally. But the pirate are lazy so you must find the minimum number of cuts to do .
input explanation: the first number will be the number of silver and gold coins combined. which there will be equal amount of. Them on the next line there would be the line of 1 and 0 to represent the coins with spaces to separate them.
example input:
8
1 0 1 0 1 0 1 0
output:
1
4 5
explanation of output: the first number will be the amount of cuts you would do. Then the next line would be the coordinates of the cut for example between the 4th and 5 coins
I already made something to intake all the coin and the numbers but I can't figure out what to do with them. Could you steer me in the right direction. I was thinking of finding the biggest palendrom number but that doesnt work on 101010
1 2 3 4 5 6 7 8 9 10
#include <iostream>
usingnamespace std;
int main() {
int n;
cin>>n;
int numbers[n];
for(int i=0;i<n;i++){
cin>>numbers[n];
}
}
@dutch input:
6
1 1 1 0 0 0
Output
3
2 3 3 4 4 5
Explanation
1 1| 1 | 0 |0 0 this cut makes it so that it between 2 and 3, 3 and 4, 4 and 5 to make it equally work the minimum amount of cut
Sorry for bad English
Oh no my teacher told me it's just another way of implying that their both even numbers
There is also
Input:
12
1 0 0 0 1 1 0 1 0 1 0 1
Output
3
3 4 6 7 9 10
Well, you've now given us two sample outputs which are both wrong. Please give us some correct ones.
I've yet to come up with any examples that need more than 2 cuts. Tentatively, I think that's what happens. Everything is either of the form:
1 cut:
A.....A | B.....B
or
2 cuts:
A...A | B.....B | A...A
If the first doesn't give balanced coins, then try all the rotations to get the second.