hdu 1299 Diophantus of Alexandria(数学题)
题目链接:hdu 1299 Diophantus of Alexandria
题意:
给你一个n,让你找1/x+1/y=1/n的方案数。
题解:
对于这种数学题,一般都变变形,找找规律,通过打表我们可以发现这个答案只与这个数的因子有关。
n=a1^p1*a2^p2*...*an^pn
ans=((1+2*p1)*(1+2*p2)*...*(1+2*pn)+1)/2
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=b;++i)
using namespace std; const int N=1e5+;
int primes[N],tot=;
bool vis[N];
void Euler(){
F(i,,N-){
if(!vis[i])primes[++tot]=i;
F(j,,tot){
if(i*primes[j]>N)break;
vis[i*primes[j]]=;
if(i%primes[j]==)break;
}
}
} int t,n,ans,cas; int main()
{
Euler();
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
ans=;
F(i,,tot)
{
if(primes[i]>n)break;
int cnt=;
while(n%primes[i]==)n/=primes[i],cnt++;
ans*=*cnt+;
}
if(n>)ans*=;
printf("Scenario #%d:\n%d\n\n",++cas,(ans+)/);
}
return ;
}
hdu 1299 Diophantus of Alexandria(数学题)的更多相关文章
- hdu 1299 Diophantus of Alexandria (数论)
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- hdu 1299 Diophantus of Alexandria
1/x + 1/y = 1/n 1<=n<=10^9给你 n 求符合要求的x,y有多少对 x<=y// 首先 x>n 那么设 x=n+m 那么 1/y= 1/n - 1/(n+ ...
- hdoj 1299 Diophantus of Alexandria
hdoj 1299 Diophantus of Alexandria 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1299 题意:求 1/x + 1/y ...
- 数学--数论--HDU 1299 +POJ 2917 Diophantus of Alexandria (因子个数函数+公式推导)
Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first ma ...
- hdu Diophantus of Alexandria(素数的筛选+分解)
Description Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of ...
- Hdu 1299
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java ...
- Diophantus of Alexandria[HDU1299]
Diophantus of Alexandria Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- HDU 1299 基础数论 分解
给一个数n问有多少种x,y的组合使$\frac{1}{x}+\frac{1}{y}=\frac{1}{n},x<=y$满足,设y = k + n,代入得到$x = \frac{n^2}{k} + ...
- Diophantus of Alexandria
Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first ma ...
随机推荐
- 搭建开发框架Express,实现Web网站登录验证
NodeJS学习笔记(一)——搭建开发框架Express,实现Web网站登录验证 JS是脚本语言,脚本语言都需要一个解析器才能运行.对于写在HTML页面里的JS,浏览器充当了解析器的角色.而对于需 ...
- 在 InstantRails 环境下,安装使用 redMine
在 InstantRails 环境下,安装使用 redMine 分类: Redmine2009-06-01 10:35 732人阅读 评论(0) 收藏 举报 characterrailsencodin ...
- Ninject是一款.Net平台下的开源依赖注入框架
Ninject是一款.Net平台下的开源依赖注入框架.按照官方说法,它快如闪电.超级轻量,且充分利用了.Net的最新语法,使用Lambda表达式代替Xml文件完成类型绑定.Ninject结构精巧,功能 ...
- SQLServer数据库误删数据找回
记一次SQLServer数据库误删数据找回 昨天 同事在本机清理数据库表时,连接到了生产机,误删了二十几张表,幸好是晚上加班的时候删除的,生产机上当时是一天一备份,还原备份是最后的策略,最关键的还是要 ...
- Binder机制,从Java到C (4. Parcel)
1. 远程调用的数据传输 在远程的函數中,必然会需要传递一些数据,那这些数据是怎么传输的呢? 在IPC中,Proxy端的作用就是将一些参数打包,然后发送出去,下面是在Proxy端经常会遇见的调用远程方 ...
- CentOS6.8安装mysql5.6
一.下载mysql5.6 下载地址,并上传至Linux 二.查看CentOS是否自带的mysql rpm -qa | grep mysql 三.卸载自带的mysql rpm -e --nodeps m ...
- 迟到的 WPF 学习 —— 路由事件
1. 理解路由事件:WPF 通过事件路由(event routing)概念增强了传统的事件执行的能力和范围,允许源自某个元素的事件由另一个元素引发,例如,事件路由允许工具栏上的一个按钮点击的事件在被代 ...
- Linux 环境进程间通信(六):
linux下进程间通信的几种主要手段: 管道(Pipe)及有名管道(named pipe):管道可用于具有亲缘关系进程间的通信,有名管道克服了管道没有名字的限制,因此,除具有管道所具有的功能外,它还允 ...
- WebLogic使用SSH架构部署遇到org.hibernate.hql.internal.ast.HqlTok
其实这个问题在以前就遇到过,当时解决了,但今天在部署一个测试轻应用的时候一直没有想起来,特此记录一下. 这个问题出现在使用WebLogic(我使用的是10.3.5版本)发布SSH架构的应用.在操作数据 ...
- 开发者所需要知道的iOS7 SDK新特性
iOS 7 春风又绿加州岸,物是人非又一年.WWDC 2013 keynote落下帷幕,新的iOS开发旅程也由此开启.在iOS7界面重大变革的背后,开发者们需要知道的又有哪些呢.同去年一样,我会先简单 ...