2721: [Violet 5]樱花
2721: [Violet 5]樱花
Time Limit: 5 Sec Memory Limit: 128 MB
Submit: 547 Solved: 322
[Submit][Status][Discuss]
Description
.gif)
Input
.gif)
Output
.gif)
Sample Input
Sample Output
HINT
.gif)
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]樱花的更多相关文章
- 【BZOJ 2721】 2721: [Violet 5]樱花 (筛)
2721: [Violet 5]樱花 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 599 Solved: 354 Description Input ...
- bzoj 2721[Violet 5]樱花 数论
[Violet 5]樱花 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 671 Solved: 395[Submit][Status][Discuss ...
- [BZOJ 2721] [Violet 5] 樱花 【线性筛】
题目链接:BZOJ - 2721 题目分析 题目大意:求出 1 / x + 1 / y = 1 / n! 的正整数解 (x, y) 的个数. 显然,要求出正整数解 (x, y) 的个数,只要求出使 y ...
- 2721: [Violet 5]樱花|约数个数
先跪一发题目背景QAQ 显然x,y>n!,然后能够设y=n!+d 原式子能够化简成 x=n!2d+n! 那么解的个数也就是n!的因子个数,然后线性筛随便搞一搞 #include<cstdi ...
- 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 ...
- BZOJ_2721_[Violet 5]樱花_数学
BZOJ_2721_[Violet 5]樱花_数学 Description Input Output $\frac{1}{x}+\frac{1}{y}=\frac{1}{m}$ $xm+ym=xy$ ...
- 【BZOJ2721】[Violet 5]樱花 线性筛素数
[BZOJ2721][Violet 5]樱花 Description Input Output Sample Input 2 Sample Output 3 HINT 题解:,所以就是求(n!)2的约 ...
- BZOJ2721 [Violet 5]樱花
先令n! = a: 1 / x + 1 / y = 1 / a => x = y * a / (y - a) 再令 k = y - a: 于是x = a + a ^ 2 / k => ...
- 【bzoj2721】[Violet 5]樱花
题目传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=2721 好久没做数学题了,感觉有些思想僵化,走火入魔了. 这道题就是求方程$ \frac ...
随机推荐
- SummerVocation_Learning--StringBuffer类
java.lang.StringBuffer代表可变的字符序列.与String类基本类似. 常见的构造方法: StringBuffer(),创建一个不包含字符序列的空的StringBuffer对象. ...
- hibernate系列之二
首先先介绍一下持久化: 持久化:将程序数据在持久状态和瞬时状态间转换的机制:即将内存的数据永久存在关系型数据库中: 持久化类的编写规则: 持久化类需要提供无参构造方法: 持久化类的属性需要私有,对私有 ...
- python3.7 time模块
#!/usr/bin/env python __author__ = "lrtao2010" #python3.7 time模块 #time模块没有time.py文件,是内置到解释 ...
- 按时按登录IP记录Linux所有用户操作日志的方法(附脚本)
PS:Linux用户操作记录一般通过命令history来查看历史记录,但是如果因为某人误操作了删除了重要的数据,这种情况下history命令就不会有什么作用了.以下方法可以实现通过记录登陆IP地址和所 ...
- xcode6没有prefix.pch预编译文件解决办法
注意到Xcode6创建的工程没有prefix.pch. 于是手动创建. 在other下选择pch文件 接着到工程的build setting下设置开启预编译并配置路径(文件的路径.因为我新建在cofi ...
- 【Interleaving String】cpp
题目: Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example,Given: ...
- 【word ladder】cpp
题目: Given two words (beginWord and endWord), and a dictionary, find the length of shortest transform ...
- 【Copy List with Random Pointer】cpp
题目: A linked list is given such that each node contains an additional random pointer which could poi ...
- leetcode 【Search a 2D Matrix 】python 实现
题目: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the f ...
- Webapp和后端交互检查测试
除了功能,我们可以使用下面方法,查看交互过程,页面不能发现的问题: 什么是json 什么是json,json是什么,json如何使用 JSON是一种取代XML的数据结构,和xml相比,它更小巧但描述能 ...