In how many ways can 5 students line up for a group photograph if 2 of the 5 are not on speaking terms and will not stand next to each other
To find the number of ways in which the 5 students can line up without the two who do not want to stand together standing next to each other, let us start with the opposite case.
The number of ways the students can line up if the two students always stand together is equal to 4!*2!. This is arrived at by considering the two students as one unit. There are now 4 units which need to be arranged. That can be done in 4! ways. Also, the two students themselves can switch places within the same unit. That gives the 2!.
The total number of arrangements of the 5 students with no constraints is 5!. As we have found the number of arrangements possible with the 2 students always standing together, the number of arrangements in which they never stand together is 5! - 4!*2! = 72.
The number of ways in which the 5 students can line up with two of them never standing next to each other is 72.