#include <bits/stdc++.h> using namespace std; int yueshu(int x){ if(x == 1) return 1; else if(x == 0) return 0; else { int count = 0; int newx = sqrt(x); for(int i = 1;i <= newx;i++){ if(x % i == 0) count = count + 2; } if(newx *newx == x) count --; return count; } } int main(){ int n; long long number; while(cin >> n){ for(int i = 0 ; i < n; i ++){ cin >> number; cout << yueshu(number) << endl; } } }
判断约数的个数,可以对数字的根号sqrt为终值,如果存在则+2,如果sqrt*sqrt等于数字本身,则结果最后再减去1