求约数的个数(模板)

#include <iostream>
#include <set>
#include <cmath>
using namespace std;
int main()
{
    int n;
    while(cin>>n&&n)
    {
        int ans=1;
        int e=2;
        while(n!=1)
        {
            int t=1;
            while(n%e==0)
            {
                n=n/e;
                t++;
            }
            e++;
            ans*=t;
        }
        cout<<ans<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/Septembre_/article/details/82949686