Count the Divisors
easyMath & Number Theory+10 XPTime limit 2s
A teacher wants to arrange n chairs into a rectangle with the same number of chairs in every row. Each way corresponds to a divisor of n (the number of chairs per row). For n = 12 the divisors are 1, 2, 3, 4, 6, 12 — that is 6 ways.
For each n, print how many divisors it has.
Input:
- line 1:
q - next
qlines: one integerneach
Output: q lines — the number of divisors of each n.
Constraints: 1 ≤ q ≤ 200, 1 ≤ n ≤ 10⁹.
Think about it: divisors come in pairs (d, n/d), and one of each pair is at most √n. Loop d from 1 while d·d ≤ n: every d that divides n gives two divisors — or just one when d·d = n.
Sample input 1
3 12 1 7
Sample output 1
6 1 2
Sample input 2
2 36 100
Sample output 2
9 9
Read input from standard input and print the answer to standard output. Your code runs in a secure sandbox against the samples (Run) and hidden tests (Submit).