题解 | #约数的个数#

约数的个数

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

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int n;
    while (cin >> n) { 
        for(int i=1;i<=n;i++)
        {
            int x;cin>>x;
            int bound=sqrt(x);
            int count=0;
            for(int j=1;j<=bound;j++)
            {
                
                if(x%j==0)
                {
                    if(j==x/j)count++;
                    else
                    count+=2;
                }
            }
            if(count!=0)cout<<count<<endl;
            
        }
    }
}

全部评论

相关推荐

Java抽象带篮子:简历怎么写可以看看我发的帖子,你的第一个是实习经历吗?那怎么写的是你的第一个练手项目呢?简历写的怎么样直接投小厂面试一下就知道了
没有实习经历,还有机会进...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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