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 ( ...
随机推荐
- STORM_0004_windows下zookeeper的伪集群的搭建
-----------------------------------------------------START------------------------------------------ ...
- .htaccess文件 301重定向URL重写[NC][R][F][L]是什么意思
.htaccess中的[NC][R][F][L]几个标记是什么意思 NC: no case,就是说不区分大小写 R:redirect,重定向 F:forbidden,禁止访问 L:last,表示已经是 ...
- Log4j XML 配置
Xml代码 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configurat ...
- iOS - UIPickerView
前言 NS_CLASS_AVAILABLE_IOS(2_0) __TVOS_PROHIBITED @interface UIPickerView : UIView <NSCoding, UITa ...
- java程序设计单一原则
在我的程序设计中一般一个类就负责一个职责 ex: class Animal{ public void brether(String animal){ System.out.println(animal ...
- 抓包工具__Windows
我常使用的: 1. SoftPerfect Network Protocol Analyzer 2. fiddler . fiddler2 3.
- css3动画导航实现
代码 <!DOCTYPE html> <!-- saved from url=(0223)file:///C:/Users/user/AppData/Local/Temp/HZ$D. ...
- php提示:Call to undefined function curl_init
我要利用curl函数进行数据采集时发现提示Call to undefined function curl_init错误了,后来从官网了解到因为curl默认不是php开启的函数,我们需要手工打开哦,下面 ...
- jQuery学习笔记:attr()与prop()的区别
先看看官方文档是如何解释两者之间功能差异的: attr() Get the value of an attribute for the first element in the set of matc ...
- 【摘抄】meta系列用法总结【持续更新中】
meta标签分两大部分:HTTP标题信息(HTTP-EQUIV)和页面描述信息(NAME). ★页面描述信息NAME变量 name是描述网页的,对应于Content(网页内容),以便于搜索引擎机器人 ...