hdu 1299 Diophantus of Alexandria

简介:

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1299
题目大意:

求方程1/x+1/y=1/n的解的个数

分析:

1/x+1/y = 1/n 设y = n + k;

==>1/x + 1/(n+k)=1/n;

==>x = n^2/k + n;

因为x为整数,k就是n^2的约数。

/*Heal The World
There's a place in your heart
And I know that it is love
And this place could be much
Brighter than tomorrow
And if you really try
You'll find there's no need to cry
In this place you'll feel
There's no hurt or sorrow
There are ways to get there
If you care enough for the living
Make a little space
Make a better place
Heal the world
Make it a better place
For you and for me
And the entire human race
There are people dying
If you care enough for the living
Make it a better place
For you and for me
If you want to know why
There's love that cannot lie
Love is strong
It only cares of joyful giving
If we try we shall see
In this bliss we cannot feel
Fear od dread
We stop existing and start living
The it feels that always
Love's enough for us growing
So make a better world
Make a better place
Heal the world
Make it a better place
For you and for me
And the entire human race
There are people dying
If you care enough for the living
Make a better place for you and for me
And the dream we were conceived in
Will reveal a joyful face
And the world we once believed in
Will shine again in grace
Then why do we keep strangling life
Wound this earth' crucify its soul
Though it's plain to see
This world is heavenly
Be god's glow
We could fly so high
Let our spirits never die
In my heart I feel you are all my brothers
Create a world with no fear
Together we cry happy tears
See the nations turn
their swords into plowshares
We could really get there
If you cared enough for the living
Make a little space
To make a better place
Heal the world
Make it a better place
For you and for me
And the entire human race
There are people dying
If you care neough for the living
Make a better place for you and for me
Heal the world
Make it a better place
For you and for me
And the entire human race
There are people dying
If you care neough for the living
Make a better place for you and for me
Heal the world
Make it a better place
For you and for me
And the entire human race
There are people dying
If you care neough for the living
Make a better place for you and for me
There are pepole dying
If you care enough for the living
*/

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn=1e7+5;
typedef long long LL;
bool prime[maxn];
int p[maxn/10];//素数
int k;//一共有多少个素数
int num[1000];//素因子的个数,注意这里不要开的太大,容易超内存
int cnt;//多少个素因子
void isprime()//素数筛
{
    k=0;
    LL i,j;//注意long long 
    memset(prime, true, sizeof(prime));
    for(LL i=2; i<maxn; i++)
    {
        if(prime[i])
        {
            p[k]=i;
            k++;
            for(j=i*i; j<maxn; j+=i)
            prime[j]=false;
        }
    }
}
LL fenjie(LL n)//素因子分解
{
    cnt=0;
    LL ans=1;
    memset(num, 0, sizeof(num));
    for(int i=0; p[i]*p[i]<=n&&i<k; i++)
    {
        if(n % p[i] == 0)
        {
            //fac[cnt]=p[i];
            while(n%p[i]==0)
            {
                num[cnt]++;
                n/=p[i];
            }
            cnt++;
        }
    }
    if(n>1)
    {
        //fac[cnt]=n;
        num[cnt++]=1;
    }
    for(int i=0;i<cnt;i++)//n*n的个数
        ans*=(2*num[i]+1);
    return ans;
}
int main()
{
    isprime();
    int m,cas=1;
    scanf("%d",&m);
    while(m--)
    {
        LL x;
        scanf("%lld",&x);
        printf("Scenario #%d:\n%lld\n\n",cas++,(fenjie(x)+1)/2);
    }
    return 0;
}
目录
相关文章
|
数据中心
SFP+ DAC高速线缆与10G光模块,谁才是10G网络的最佳选择?
数据中心网络从最初的100M,1G,10G,到40G和100G,高速以太网的发展从未停止。10G以太网(IEEE802.3ae)的标准于2002年批准,在10G网络中,工程师在布线中需要考虑选择光纤还是铜缆,大家都希望选择一个性价比高的方案。
2815 0
|
7天前
|
机器学习/深度学习 人工智能 自然语言处理
构建AI智能体:五十七、LangGraph + Gradio:构建可视化AI工作流的趣味指南
本文介绍了一个基于LangGraph和Qwen大模型的可视化智能工作流系统,旨在降低AI应用门槛,让非技术用户也能轻松组合各种AI能力。系统通过四层处理引擎(预处理、情感分析、关键词提取、智能回复)自动化处理用户反馈,相比传统人工方式可大幅提升效率和质量。文章详细展示了系统架构设计、代码实现和可视化交互界面,并提供了电商客服场景的应用案例。该系统将复杂的大模型能力封装成模块化工作流,支持实时流程监控和灵活配置,有效解决了传统用户反馈处理中效率低下、标准不一等痛点。
|
10天前
|
人工智能 自然语言处理 安全
从0.8秒到全栈私有化,集之互动数字人公司如何重塑行业交互标准
在AIGC浪潮下,集之互动(ZITZO)以0.8秒极速交互、全栈私有化部署和深度行业融合,重新定义数字人为“智能运营伙伴”。其技术赋能医疗、政务、零售等300+头部企业,推动AI从展示走向生产力,引领安全、高效的数智化未来。
82 1
|
自然语言处理 监控 Cloud Native
对话阿里云云原生产品负责人李国强:推进可观测产品与OpenTelemetry开源生态全面融合
阿里云宣布多款可观测产品全面升级,其中,应用实时监控服务 ARMS 在业内率先推进了与 OpenTelemetry 开源生态的全面融合,极大丰富了可观测的数据类型及规模,大幅增强了 ARMS 核心能力。本次阿里云 ARMS 产品全面升级的背景是什么?为什么会产生围绕 OpenTelemetry 进行产品演进的核心策略?在云原生、大模型等新型应用架构类型层出不穷的今天,又将如何为企业解决新的挑战?阿里云云原生应用平台产品负责人李国强接受采访解答了这些疑问,点击本文走进全新升级的阿里云可观测产品。
42302 104
|
监控 安全 网络安全
WPA2 与 802.1X:有什么区别?
【10月更文挑战第17天】
1140 1
WPA2 与 802.1X:有什么区别?
|
弹性计算
阿里云服务器10M带宽收费价格详解
带宽是衡量网络传输能力的重要指标,对于云服务器的性能有着至关重要的影响。阿里云作为领先的云服务提供商,为用户提供了多种带宽选择,以满足不同应用场景的需求。本文将详细介绍阿里云服务器10M带宽的收费价格、地域差异以及优惠政策,帮助您更好地了解并选择合适的带宽方案。
|
存储 JSON 安全
在项目中到底应不应该用jwt?
JSON Web Tokens(JWT)是一种开放标准,用于在网络上传输安全信息。它常用于身份验证场景,用户登录后,服务器生成JWT并返回给客户端。客户端在后续请求中携带此令牌,服务器验证其有效性来确认用户身份。JWT具有无状态、可扩展和安全的特点,支持跨域认证,但也有令牌大小、续期复杂等缺点。是否使用JWT取决于项目需求,多数公司在采用,除非有特殊理由避免。以下是Go语言中使用JWT的一个示例。
386 0
|
机器学习/深度学习 Shell Python
利用Anaconda完成Python环境安装及配置
Anaconda及Pycharm安装流程及相关报错
389 0
|
设计模式 数据可视化 Java
Spring 事件处理机制详解,带你吃透 Spring 事件
前言 Spring 事件处理基于 Java 观察者模式扩展。Spring 应用上下文中发布了各种事件,此外 Spring 还允许我们发送和处理自定义的事件,本篇将对 Spring 的事件机制使用及其实现进行详细介绍。
1532 0
Spring 事件处理机制详解,带你吃透 Spring 事件