题解 | #约数的个数#
约数的个数
https://www.nowcoder.com/practice/04c8a5ea209d41798d23b59f053fa4d6
#include <stdio.h> #include <math.h> int ApproxiNum(long long x) { if (x == 1) return 1; else { long long y = sqrt(x); int count = 0; for (long i = 1; i <= y; i++) { if (x % i == 0 && i * i != x) count += 2; else if (x % i == 0 && i * i == x) count++; } return count; } } int main() { int n; scanf("%d", &n); int Arr[n]; int i = 0; while (n--) { long long m = 0; scanf("%lld", &m); Arr[i++] = ApproxiNum(m); } for (int k = 0; k < i; k++) printf("%d\n", Arr[k]); return 0; }