It's Christmas time in the forest, and both the fox and the wolf families are celebrating. The rather large fox family consists of two parents as well as N (1 ≤ N ≤ 1,000,000,000) little foxlings. The parents have decided to give their children a special treat this year - crackers! After all, it's a well-known fact that foxen love crackers.
With such a big family, the parents can't afford that many crackers. As such, they wish to minimize how many they give out, but still ensuring that each foxling gets at least a bit. The parents can only give out entire crackers, which can then be divided and passed around.
With this many children, not all of them know one another all that well. The foxlings have names, of course, but their parents are computer scientists, so they have also conveniently numbered them from 1 to N. There are M (1 ≤ M ≤ 100,000) unique two-way friendships among the foxlings, where relationship i is described by the distinct integers Ai and Bi (1 ≤ Ai, Bi ≤ N), indicating that foxling Ai is friends with foxling Bi, and vice versa. When a foxling is given a cracker, he can use his tail to precisely split it into as many pieces as he wants (the tails of foxen have many fascinating uses). He can then pass these pieces around to his friends, who can repeat this process themselves.
Line 1: Two integers - N and M
Next M lines: Two integers - Ai and Bi
OutputThe minimum number of crackers that must be given out so that each fox ends up with at least a bit of a cracker.
9 5 3 1 6 1 7 6 2 7 8 9
The parents can give one cracker to foxling 6, who will then split it into three and give pieces to his friends (foxlings 1 and 7). Foxling 7 can then give half of his piece to his other friend, foxling 2.
They can give another cracker to foxling 8, who will split it with foxling 9.
This leaves foxlings 4 and 5, who have no friends (don't worry, foxen have long since outgrown the need for friends), and who must be given one cracker each. This brings the total up to 4 crackers.
Point Value: 10 (partial)
Time Limit: 2.00s
Memory Limit: 16M
Added: Mar 11, 2009
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3