[数学][思维][结论] HDU1299 Diophantus of Alexandria

https://cn.vjudge.net/problem/HDU-1299

学到了设k求整数解个数的方法?emmm似乎非常常用的样子
wa在ans写在if外面了,这样会多乘。。。


#include 
#include
#include
#include
#include

using namespace std;

typedef long long LL;

LL getn(int A)
{
    LL TA=A;
    LL ans=1;
    LL k=0;
    if(A%2==0)
    {
        k=0;
        while(!(A%2))
        {
            k++;
            A/=2;
        }
    }
    ans*=((k<<1)+1);
    for(int i=3;i*i<=A;i+=2)
    {
        if(A%i==0)
        {
            k=0;
            while(!(A%i))
            {
                k++;
                A/=i ;
            }
            ans*=((k<<1)+1);//error
        }
    }
    if(A!=1)
    {
        ans*=3;
    }
    //cout<
	

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据