BZOJ2721 [Violet 5]樱花
先令n! = a:
1 / x + 1 / y = 1 / a => x = y * a / (y - a)
再令 k = y - a:
于是x = a + a ^ 2 / k => k | a ^ 2
故等价于求a ^2的约数个数
素数筛一下什么的就好了嘛
/**************************************************************
Problem: 2721
User: rausen
Language: C++
Result: Accepted
Time:588 ms
Memory:2408 kb
****************************************************************/ #include <cstdio> using namespace std;
typedef long long ll;
const int N = ;
const int Cnt = ;
const int mod = ; int n;
bool F[N];
int cnt, p[Cnt], c[Cnt];
ll ans = ; int main() {
int i, j, t;
scanf("%d\n", &n);
for (i = ; i < N; ++i) {
if (!F[i]) p[++cnt] = i;
for (j = ; j <= cnt && p[j] * i < N; ++j) {
F[p[j] * i] = ;
if (p[j] % i == ) break;
}
}
for (i = ; i <= cnt; ++i)
for (j = p[i]; j <= n; j += p[i])
for (t = j; t % p[i] == ; t /= p[i]) ++c[i];
for (i = ; i <= cnt; ++i)
(ans *= (c[i] << | )) %= mod;
printf("%lld\n", ans);
return ;
}
BZOJ2721 [Violet 5]樱花的更多相关文章
- 【筛法求素数】【质因数分解】bzoj2721 [Violet 5]樱花
http://www.cnblogs.com/rausen/p/4138233.html #include<cstdio> #include<iostream> using n ...
- 2018.10.26 bzoj2721: [Violet 5]樱花(数论)
传送门 推一波式子: 1x+1y=1n!\frac 1 x+\frac 1 y=\frac 1 {n!}x1+y1=n!1 =>xy−x∗n!−y∗n!xy-x*n!-y*n!xy−x∗n ...
- 【BZOJ2721】[Violet 5]樱花 线性筛素数
[BZOJ2721][Violet 5]樱花 Description Input Output Sample Input 2 Sample Output 3 HINT 题解:,所以就是求(n!)2的约 ...
- BZOJ_2721_[Violet 5]樱花_数学
BZOJ_2721_[Violet 5]樱花_数学 Description Input Output $\frac{1}{x}+\frac{1}{y}=\frac{1}{m}$ $xm+ym=xy$ ...
- 【BZOJ 2721】 2721: [Violet 5]樱花 (筛)
2721: [Violet 5]樱花 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 599 Solved: 354 Description Input ...
- 2721: [Violet 5]樱花
2721: [Violet 5]樱花 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 547 Solved: 322[Submit][Status][D ...
- bzoj 2721[Violet 5]樱花 数论
[Violet 5]樱花 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 671 Solved: 395[Submit][Status][Discuss ...
- 【bzoj2721】[Violet 5]樱花
题目传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=2721 好久没做数学题了,感觉有些思想僵化,走火入魔了. 这道题就是求方程$ \frac ...
- Bzoj2721 [Violet]樱花(筛法)
题面 题解 首先化一下式子 $$ \frac 1x+\frac 1y=\frac 1{n!} \Rightarrow \frac {x+y}{xy}=\frac 1{n!} \Rightarrow ( ...
随机推荐
- SQL——连接查询
以mysql为例: 新建两张表table1和table2 CREATE TABLE `table1` ( `id` ) NOT NULL auto_increment, `name` ) defaul ...
- CI实践_Android持续集成
之前已经实现了Android的持续集成,并在项目中应用了一段时间.恰逢现在有几分钟时间,把之前的一些零散的点滴记录和整理一下,供有需要的朋友参考,或后续复用. 需要的准备知识:gitlab.Jenki ...
- 关于Docker在测试方面的应用
Docker 火了很长一段时间了,前段时间简单的学习和试玩了一下子,发现他对测试很有价值,觉得有必要再次深入研究. 这里标记一些较好的学习网址,用作参考: InfoQ上面有系列的文章: 深入浅出Doc ...
- C#线程系列讲座(5):同步技术之Monitor
在上一讲介绍了使用lock来实现线程之间的同步.实际上,这个lock是C#的一个障眼法,在C#编译器编译lock语句时,将其编译成了调用Monitor类.先看看下面的C#源代码: public sta ...
- org.apache.http.client.CircularRedirectException: Circular redirect to "http://xxx"问题解决
org.apache.http.client.CircularRedirectException: Circular redirect to "http://xxx"问题解决 ...
- JS 拼装代码的HTML onClick方法传递字符串
有时会在JS中拼装HTML代码,这时在HTML中出现的onClick()方法中: 1.出现传递Num型的数据,直接拼装进去即可: 2.可能会出现传递字符串的情况,处理方法比较特殊,如下: a:直接字符 ...
- [转载] Go语言并发之美
原文: http://qing.blog.sina.com.cn/2294942122/88ca09aa33002ele.html 简介 多核处理器越来越普及,那有没有一种简单的办 ...
- 2014 Multi-University Training Contest 4
1006 hdu4902 #include <iostream> #include<stdio.h> #include<vector> #include<qu ...
- mysql 并发控制
1.多个线程同时修改数据,存在数据不一致的情况,也就是并发控制的问题.2.mysql提供读锁和写锁,读锁之上可以再加读锁,不能加写锁,而写锁之上不能加任何锁.也就是说,读锁是共享的,写锁是排他的.3. ...
- 2 CSS
2 CSS CSS基础 html 在一个网页中负责的事情是一个页面的结构css(层叠样式表) 在一个网页中主要负责了页面的数据样式. 编写css代码的方式: 第一种: 在style标签中编写c ...