http://www.lydsy.com/JudgeOnline/problem.php?id=3629

约数和定理:

若n的标准分解式为 p1^k1 * p2^k2 ……

那么n的约数和= π (Σ pi^xi ) xi∈[0,ki]

原本枚举小于S的质数,通过先判断S-1是不是质数 就可以 枚举根号S内的质数

#include<cstdio>
#include<algorithm> using namespace std; #define N 1000000 int prime[N+],cnt;
bool vis[N+]; int ans[N],tot; void pre()
{
vis[]=true;
for(int i=;i<=N;++i)
{
if(!vis[i]) prime[++cnt]=i;
for(int j=;j<=cnt;++j)
{
if(i*prime[j]>N) break;
vis[i*prime[j]]=true;
if(!(i%prime[j])) break;
}
}
} bool isprime(int x)
{
if(x<=N) return !vis[x];
for(int i=;prime[i]*prime[i]<=x;++i)
if(!(x%prime[i])) return false;
return true;
} void dfs(int last,int num,int rest)
{
if(rest==) { ans[++tot]=num; return; }
if(rest->prime[last] && isprime(rest-)) ans[++tot]=num*(rest-);
for(int i=last+;prime[i]*prime[i]<=rest;++i)
for(int sum=prime[i]+,nnum=prime[i];sum<=rest;nnum*=prime[i],sum+=nnum)
if(!(rest%sum)) dfs(i,num*nnum,rest/sum);
} int main()
{
pre();
int n;
while(scanf("%d",&n)!=EOF)
{
tot=;
dfs(,,n);
sort(ans+,ans+tot+);
printf("%d\n",tot);
for(int i=;i<=tot;++i) printf("%d ",ans[i]);
if(tot) printf("\n");
}
}

bzoj千题计划297:bzoj3629: [JLOI2014]聪明的燕姿的更多相关文章

  1. bzoj3629[JLOI2014]聪明的燕姿

    http://www.lydsy.com/JudgeOnline/problem.php?id=3629 搜索. 我们知道: 如果$N=\prod\limits_{i=1}^{m}p_{i}^{k_{ ...

  2. 2018.09.11 bzoj3629: [JLOI2014]聪明的燕姿(搜索)

    传送门 一道神奇的搜索. 直接枚举每个质因数的次数,然后搜索就行了. 显然质因数k次数不超过logkn" role="presentation" style=" ...

  3. bzoj3629 [JLOI2014]聪明的燕姿——DFS+约数和定理

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3629 扫除了一个知识盲点:约数和定理 约数和定理: 对于一个大于1正整数n可以分解质因数:n ...

  4. bzoj3629 / P4397 [JLOI2014]聪明的燕姿

    P4397 [JLOI2014]聪明的燕姿 根据唯一分解定理 $n=q_{1}^{p_{1}}*q_{2}^{p_{2}}*q_{3}^{p_{3}}*......*q_{m}^{p_{m}}$ 而$ ...

  5. 【LG4397】[JLOI2014]聪明的燕姿

    [LG4397][JLOI2014]聪明的燕姿 题面 洛谷 题解 考虑到约数和函数\(\sigma = \prod (1+p_i+...+p_i^{r_i})\),直接爆搜把所有数搜出来即可. 爆搜过 ...

  6. BZOJ_3629_[JLOI2014]聪明的燕姿_dfs

    BZOJ_3629_[JLOI2014]聪明的燕姿_dfs Description 阴天傍晚车窗外 未来有一个人在等待 向左向右向前看 爱要拐几个弯才来 我遇见谁会有怎样的对白 我等的人他在多远的未来 ...

  7. P4397 [JLOI2014]聪明的燕姿

    P4397 [JLOI2014]聪明的燕姿 题目背景 阴天傍晚车窗外 未来有一个人在等待 向左向右向前看 爱要拐几个弯才来 我遇见谁会有怎样的对白 我等的人他在多远的未来 我听见风来自地铁和人海 我排 ...

  8. bzoj千题计划300:bzoj4823: [Cqoi2017]老C的方块

    http://www.lydsy.com/JudgeOnline/problem.php?id=4823 讨厌的形状就是四联通图 且左右各连一个方块 那么破坏所有满足条件的四联通就好了 按上图方式染色 ...

  9. bzoj千题计划196:bzoj4826: [Hnoi2017]影魔

    http://www.lydsy.com/JudgeOnline/problem.php?id=4826 吐槽一下bzoj这道题的排版是真丑... 我还是粘洛谷的题面吧... 提供p1的攻击力:i,j ...

随机推荐

  1. [转帖] linux下面 vim 数字键无法插入的解决办法

    感谢原作者: https://blog.csdn.net/guoyuqi0554/article/details/11477597 这个问题困扰自己好久了.. 刚才解决了 rlwrap的问题 这会儿 ...

  2. QC

    IQC:Incoming Quality Control 意思是来料的质量控制  来料 IPQC:InPut Process Quality Control 过程质量控制   来料 FQC:Final ...

  3. 周刷题第二期总结(Longest Substring Without Repeating Characters and Median of Two Sorted Arrays)

    这周前面刷题倒是蛮开心,后面出了很多别的事情和问题就去忙其他的,结果又只完成了最低目标. Lonest Substring Without Repeating Characters: Given a ...

  4. flask客户端测试使用设置cookie参数

    今天在对flask客户端进行测试,然后看到我们服务器端用请求前钩子写了这样的代码 @app.before_requestdef before_request(): session = request. ...

  5. SourceTree 如何下载git 管理的代码-如何创建分支,删除分支,提交代码,回退代码

    把用户给的链接拿过来,然后输入浏览器,然后在左侧会有Actions 中有个Clone;点击Clone之后,有个 Clone in Source Tree 点击,打开你的本地Source Tree,然后 ...

  6. HTML5 & how to download SVG in js

    HTML5 & how to download SVG in js how to download SVG in js http://dinbror.dk/blog/how-to-downlo ...

  7. MySQL基本概念以及简单操作

    一.MySQL   MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于Oracle 旗下产品.MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MyS ...

  8. 百度/头条合作命中注定!中国新BAT要来了

    据外媒报道,今日头条母公司字节跳动(ByteDace)将为中国互联网传统BAT的格局,带来一些新的活力.这家增速飞快的新闻.视频App“制造者”已经估值高达750亿美元,与三巨头之一的百度平起平坐,后 ...

  9. 关于mysql性能压测之tpcc

    软件下载: wget http://imysql.com/wp-content/uploads/2014/09/tpcc-mysql-src.tgz安装依赖:yum install -y mysql- ...

  10. 03 Zabbix4.0添加cisco交换机基本监控步骤

    点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 03 Zabbix4.0添加cisco交换机基本监控步骤 主题监控一台cisco网络设备的6项内容 ...