题解 | #约数的个数#

约数的个数

https://www.nowcoder.com/practice/04c8a5ea209d41798d23b59f053fa4d6

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int main() {
    int N = 0;
    while (cin >> N) {
        for (int i = 0; i < N; i++) {
            int j;
            long long int x;
            int yueshu = 0;
            cin >> x;
            for ( j = 1; j < sqrt(x); j++) {
                if (x % j == 0)yueshu+=2;
            }
            if (j*j==x) {
                yueshu++;
            }
            cout << yueshu << endl;
        }
    }
    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 11:47
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务