Here is the problem statement
http://www.spoj.com/problems/GIRLSNBS/
We nned to pick the smaller number form the two given numbers, let's assume its the number of boys which is smaller. We take the boys and distribute them in a girl sequence in a way so that the repetition can be minimum. Lets look at an example
bbb
ggggggg
We have 7 girls and 3 boys. It is possibleto ditribute the boys in a way so that there will always be at 2 consequetive girls at best. Example
ggbggbggbg
The formula for this is
answer= ceil( max(a,b)/(min(a,b)+1)) (ceil means divided and rounded up)
http://www.spoj.com/problems/GIRLSNBS/
We nned to pick the smaller number form the two given numbers, let's assume its the number of boys which is smaller. We take the boys and distribute them in a girl sequence in a way so that the repetition can be minimum. Lets look at an example
bbb
ggggggg
We have 7 girls and 3 boys. It is possibleto ditribute the boys in a way so that there will always be at 2 consequetive girls at best. Example
ggbggbggbg
The formula for this is
answer= ceil( max(a,b)/(min(a,b)+1)) (ceil means divided and rounded up)
No comments:
Post a Comment