2721: [Violet 5]樱花

Time Limit: 5 Sec  Memory Limit: 128 MB
Submit: 547  Solved: 322
[Submit][Status][Discuss]

Description

Input

Output

Sample Input

 

Sample Output

 

HINT

Source

分析:

考虑$y$大于$n!$,但是要求个数,所以不可能无限大,所以我们需要寻找的就是上界,考虑让$y=n!+t$,那么$\frac {1}{x}+\frac {1}{n!+t}=\frac {1}{n!}$...

然后化简一下:$n!(n!+t)+x(n!)=x(n!+t)-->x=\frac {n!(n!+t)}{t}-->x=\frac {(n!)^{2}}{t}+n!$...

所以个数就是$(n!)^{2}$的约数个数...

代码:

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
//by NeighThorn
using namespace std; const int maxn=1000000+5,mod=1e9+7; int n,cnt,vis[maxn],pri[maxn],num[maxn],Min[maxn]; inline void prework(void){
cnt=0;
for(int i=2;i<=n;i++){
if(!vis[i])
pri[++cnt]=i,Min[i]=cnt;
for(int j=1;j<=cnt&&pri[j]*i<=n;j++){
vis[i*pri[j]]=1,Min[i*pri[j]]=j;
if(i%pri[j]==0)
break;
}
}
} inline void calc(int x){
while(x!=1)
num[Min[x]]++,x/=pri[Min[x]];
} signed main(void){
scanf("%d",&n);prework();
for(int i=1;i<=n;i++)
calc(i);
long long ans=1LL;
for(int i=1;i<=cnt;i++)
(ans+=1LL*ans*num[i]%mod*2%mod)%=mod;
printf("%lld\n",ans);
return 0;
}

  


By NeighThorn

2721: [Violet 5]樱花的更多相关文章

  1. 【BZOJ 2721】 2721: [Violet 5]樱花 (筛)

    2721: [Violet 5]樱花 Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 599  Solved: 354 Description Input ...

  2. bzoj 2721[Violet 5]樱花 数论

    [Violet 5]樱花 Time Limit: 5 Sec  Memory Limit: 128 MBSubmit: 671  Solved: 395[Submit][Status][Discuss ...

  3. [BZOJ 2721] [Violet 5] 樱花 【线性筛】

    题目链接:BZOJ - 2721 题目分析 题目大意:求出 1 / x + 1 / y = 1 / n! 的正整数解 (x, y) 的个数. 显然,要求出正整数解 (x, y) 的个数,只要求出使 y ...

  4. 2721: [Violet 5]樱花|约数个数

    先跪一发题目背景QAQ 显然x,y>n!,然后能够设y=n!+d 原式子能够化简成 x=n!2d+n! 那么解的个数也就是n!的因子个数,然后线性筛随便搞一搞 #include<cstdi ...

  5. BZOJ 2721: [Violet 5]樱花

    (X-N)(Y-N)=N^2 #include<cstdio> using namespace std; const int mod=1e9+7; int n,cnt,isprime[10 ...

  6. BZOJ_2721_[Violet 5]樱花_数学

    BZOJ_2721_[Violet 5]樱花_数学 Description Input Output $\frac{1}{x}+\frac{1}{y}=\frac{1}{m}$ $xm+ym=xy$ ...

  7. 【BZOJ2721】[Violet 5]樱花 线性筛素数

    [BZOJ2721][Violet 5]樱花 Description Input Output Sample Input 2 Sample Output 3 HINT 题解:,所以就是求(n!)2的约 ...

  8. BZOJ2721 [Violet 5]樱花

    先令n! = a: 1 / x + 1 / y = 1 / a  =>  x = y * a / (y - a) 再令 k = y - a: 于是x = a + a ^ 2 / k  => ...

  9. 【bzoj2721】[Violet 5]樱花

    题目传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=2721 好久没做数学题了,感觉有些思想僵化,走火入魔了. 这道题就是求方程$ \frac ...

随机推荐

  1. linux分区之ext2,ext3,ext4,gpt

    linux分区之ext2,ext3,ext4,gpt 2013-07-10 12:00:24 标签:ext3 gpt 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明 ...

  2. VueX源码分析(5)

    VueX源码分析(5) 最终也是最重要的store.js,该文件主要涉及的内容如下: Store类 genericSubscribe函数 resetStore函数 resetStoreVM函数 ins ...

  3. C++性能优化笔记

    最近着手去优化项目中一个模块的性能.该模块是用C++实现,对大量文本数据进行处理. 一开始时,没什么思路,因为不知道性能瓶颈在哪里.于是借助perf工具来对程序进行分析,找出程序的性能都消耗在哪里了. ...

  4. python 进度条 打印

  5. Ubuntu18 中文乱码 问题 解决

    之前租的服务器没有中文乱码的问题,最近重装了一下系统, 出现了中文乱码, 以下是解决方案: 输入locale查看当前的语言是否是中文 root@ubuntu:~# locale LANG=zh_CN. ...

  6. swoole 连接池

    proxy_pool.php <?php class ProxyServer { protected $frontends; protected $backends; /** * @var sw ...

  7. vue.js 三(数据交互)isomorphic-fetch

    至于fetch的介绍,在这里就不多说了,官方和网络上的说明不少 之前使用jquery的Ajax朋友,可以尝试一下使用一下这个新的api 推荐使用isomorphic-fetch,兼容Node.js和浏 ...

  8. 精通SpringBoot--整合Redis实现缓存

    今天我们来讲讲怎么在spring boot 中整合redis 实现对数据库查询结果的缓存.首先第一步要做的就是在pom.xml文件添加spring-boot-starter-data-redis.要整 ...

  9. docker时区正常,但java获得的时间早了8小时解决方法

    我解决容器时区的方法是挂载宿主机的/etc/localtime 到容器的/etc/localtime,这时输入date命令容器时区显示正常,但是跑在容器中的java项目取到的时间却早了8小时. 查阅相 ...

  10. MySQL创建数据库及用户

    create database ${db_name} default charset utf8 COLLATE utf8_general_ci; grant all on ${db_name}.* t ...