Day7 - D - The Euler function HDU - 2824
InputThere are several test cases. Each line has two integers a, b (2<a<b<3000000).OutputOutput the result of (a)+ (a+1)+....+ (b)Sample Input
3 100
Sample Output
3042
思路:欧拉函数前缀和板子
typedef long long LL;
const int maxm = 3e6+;
LL Euler[maxm];
void getEuler() {
Euler[] = ;
for(int i = ; i <= maxm; ++i) {
if(!Euler[i]) {
for(int j = i; j <= maxm; j += i) {
if(!Euler[j]) Euler[j] = j;
Euler[j] = Euler[j] / i * (i-);
}
}
}
}
int main() {
int a, b;
getEuler();
for(int i = ; i <= maxm; ++i)
Euler[i] += Euler[i-];
while(scanf("%d%d", &a, &b) != EOF) {
printf("%lld\n", Euler[b] - Euler[a-]);
}
return ;
}
Day7 - D - The Euler function HDU - 2824的更多相关文章
- hdu 2824 The Euler function(欧拉函数)
题目链接:hdu 2824 The Euler function 题意: 让你求一段区间的欧拉函数值. 题解: 直接上板子. 推导过程: 定义:对于正整数n,φ(n)是小于或等于n的正整数中,与n互质 ...
- HDU——T 2824 The Euler function
http://acm.hdu.edu.cn/showproblem.php?pid=2824 Time Limit: 2000/1000 MS (Java/Others) Memory Limi ...
- hdu 2824 The Euler function
The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- hdu 2824 The Euler function 欧拉函数打表
The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDU 2824 The Euler function --------欧拉模板
The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- 欧拉函数 & 【POJ】2478 Farey Sequence & 【HDU】2824 The Euler function
http://poj.org/problem?id=2478 http://acm.hdu.edu.cn/showproblem.php?pid=2824 欧拉函数模板裸题,有两种方法求出所有的欧拉函 ...
- HDU——2824 The Euler function
The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDU - 2824 The Euler function 欧拉函数筛 模板
HDU - 2824 题意: 求[a,b]间的欧拉函数和.这道题卡内存,只能开一个数组. 思路: ϕ(n) = n * (p-1)/p * ... 可利用线性筛法求出所有ϕ(n) . #include ...
- HDU 6322.Problem D. Euler Function -欧拉函数水题(假的数论题 ̄▽ ̄) (2018 Multi-University Training Contest 3 1004)
6322.Problem D. Euler Function 题意就是找欧拉函数为合数的第n个数是什么. 欧拉函数从1到50打个表,发现规律,然后勇敢的水一下就过了. 官方题解: 代码: //1004 ...
随机推荐
- js keyCode 常用键盘编码
摘自:http://blog.csdn.net/dyllove98/article/details/8728657 keycode 8 = BackSpace BackSpace keycode 9 ...
- Servlet 学习(三)
HTTP 请求的构成 1.HTTP 请求行: 请求方式,比如 GET .POST 等 本次请求的URI ,比如 /hello 协议和版本号 2. HTTP 请求报头: (头部/首部/请求头) 请求头和 ...
- Spring Cloud常用注解
@SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.security.servlet.SecurityAu ...
- TensorFlow基础一(Symbolic Operation)
比较TensorFlow和Numpy 在Numpy中让两个随机矩阵相乘得到运算的结果: import numpy as np x = np.random.normal(size=[10, 10]) y ...
- JS 表单相关
var title = $("#subjects option:selected").text();
- Mongodb - 解决 ( aggregate聚合管道 ) $match 根据 id 匹配 返回 [ ] 的问题
需要对 id 进行转换 const mongoose = require('mongoose') var ObjectId = mongoose.Types.ObjectId; await Use ...
- Electron调用C++的DLL
1. 安装ffi-napi npm install ffi-napi 2. c++ dll 注意,若electron是X64的,则dll也应为X64,同理32位. myAddDll是c++的dll ...
- gets和scanf区别
scanf 和 gets 读取字符串 深入了解scanf()/getchar()和gets()等函数 scanf与gets函数读取字符串的区别 今天看到一段话,大致是说gets比scanf()快,有点 ...
- Flutter | 状态管理特别篇——Provide
前言 今天偶然发现在谷歌爸爸的仓库下出现了一个叫做flutter-provide的状态管理框架,2月8日才第一次提交,非常新鲜.在简单上手之后感觉就是一个字--爽!所以今天就跟大家分享一下这个新的状态 ...
- 应用间的API访问如何认证?
任何一个一个应用要访问另一个应用的API,需要首先到开放平台获取访问accesskey, 然后访问目标应用,目标应用中先检查来源访问token是否已存在缓存中,不存在需要去开放平台校验accesske ...