Patting Heads
Time limit1sMemory limit128 MB
Each of N cows has a value; for every cow count how many other cows hold a value that divides hers.
- Level
Medium5 of 10
- Topics
- Math, Number theory, Hash map, Array
- Solved
- No attempts yet
Problem
It's Bessie's birthday, and it's time for party games! Bessie has arranged the cows (), conveniently numbered , in a circle, so that cow sits between cows and , and cow sits next to cow .
Farmer John fills a barrel with a huge number of paper slips, each holding an integer between and . Each cow then draws one integer () from the barrel; the values are not necessarily distinct.
Taking turns, each cow walks around the circle and pats the head of every other cow whose number exactly divides her own number , then returns to her seat.
For each cow, determine how many other cows she pats.
Input
- Line : a single integer .
- Lines : line contains the integer .
Output
- Print lines. On line , print a single integer: the number of other cows that cow pats.
Hint
In the example, the first cow (number ) pats the second cow (number , since is divisible by ) and the third cow (number ), for a total of . The second cow (number ) pats no one, because no other cow drew a number that divides .