版权声明:本文为博主原创文章,未经博主同意不得转载。

vasttian https://blog.csdn.net/u012860063/article/details/36426357

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2824

欧拉函数性质:

1:(百科):http://baike.baidu.com/link?url=r-yneKCCyS9N6bhbQCqiZX0V2OCYq9r7iHSzHTSs03H7qRvu1OfUzlOxfVEs2PmR

2:http://www.cppblog.com/doer-xee/archive/2009/12/01/102353.html

Problem Description
The Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are smaller than n and coprime to n, and this function has a lot of beautiful characteristics. Here comes a very
easy question: suppose you are given a, b, try to calculate (a)+ (a+1)+....+ (b)
 
Input
There are several test cases. Each line has two integers a, b (2<a<b<3000000).
 
Output
Output the result of (a)+ (a+1)+....+ (b)
 
Sample Input

3 100
 
Sample Output

3042
 
Source

题意:求a到b中每一个数的欧拉函数的总和!

代码例如以下:

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define N 3000001 __int64 phi[N]; void init()
{
int i, j;
for(i = 1; i < N; i++)
phi[i] = i; for(i = 2; i < N; i++)
if(i == phi[i]) //此时i为素数
for(j = i; j < N; j += i) //j累加i
phi[j] = (phi[j] / i) * (i - 1); //j有因子i,并且i是素数,正是欧拉函数
} int main()
{
init();
int a, b;
while(scanf("%d%d", &a, &b) != EOF)
{
__int64 ans = 0;
for(int i = a; i <= b; i++)
ans += phi[i];
printf("%I64d\n", ans);
}
return 0;
}

hdu2824 The Euler function(欧拉函数个数)的更多相关文章

  1. hdu 2824 The Euler function(欧拉函数)

    题目链接:hdu 2824 The Euler function 题意: 让你求一段区间的欧拉函数值. 题解: 直接上板子. 推导过程: 定义:对于正整数n,φ(n)是小于或等于n的正整数中,与n互质 ...

  2. HDU 6322.Problem D. Euler Function -欧拉函数水题(假的数论题 ̄▽ ̄) (2018 Multi-University Training Contest 3 1004)

    6322.Problem D. Euler Function 题意就是找欧拉函数为合数的第n个数是什么. 欧拉函数从1到50打个表,发现规律,然后勇敢的水一下就过了. 官方题解: 代码: //1004 ...

  3. (hdu step 7.2.1)The Euler function(欧拉函数模板题——求phi[a]到phi[b]的和)

    题目: The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...

  4. hdu 2824 The Euler function 欧拉函数打表

    The Euler function Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  5. HDU - 2824 The Euler function 欧拉函数筛 模板

    HDU - 2824 题意: 求[a,b]间的欧拉函数和.这道题卡内存,只能开一个数组. 思路: ϕ(n) = n * (p-1)/p * ... 可利用线性筛法求出所有ϕ(n) . #include ...

  6. Euler:欧拉函数&素数筛

    一.欧拉函数 欧拉函数是小于x的整数中与x互质的数的个数,一般用φ(x)表示. 通式:   其中p1, p2……pn为x的所有质因数,x是不为0的整数. 比如x=12,拆成质因数为12=2*2*3, ...

  7. hdu-5597 GTW likes function(欧拉函数+找规律)

    题目链接: GTW likes function Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 131072/131072 K (J ...

  8. HDU 5597 GTW likes function 欧拉函数

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5597 题意: http://bestcoder.hdu.edu.cn/contests/contes ...

  9. LightOJ1370 Bi-shoe and Phi-shoe —— 欧拉函数

    题目链接:https://vjudge.net/problem/LightOJ-1370 1370 - Bi-shoe and Phi-shoe    PDF (English) Statistics ...

随机推荐

  1. Storm框架:如何实现crontab定时任务

    Storm除了能对消息流进行处理,还能实现crontab定时任务. 只要在bolt中配置TOPOLOGY_TICK_TUPLE_FREQ_SECS项即可实现. @Override public Map ...

  2. oracle数据库逐步学习总结【基础二】

    原创作品,转载请在文字开头明显位置注明出处:https://www.cnblogs.com/sunshine5683/p/10067872.html 接着上一篇,继续总结! 五.oracle表管理 首 ...

  3. Navicat MySql乱码解决

    接着上一篇博客继续解决 如上图,鼠标放在localhost上右键,选择编辑连接,弹出下图. 如下选择好之后,连接数据库,进行测试.在test数据库上右键选择命令列界面,如下图,输入show varia ...

  4. Java基础学习—思维导图

    找到两张Java学习的思维导图,特别适合我这样的菜鸟学习,贴过来和小伙伴分享.

  5. 网络I/O模型--02阻塞模式(多线程)

    当服务器收到客户端 X 的请求后(读取到所有请求数据后),将这个请求送入一个独立线程进行处理,然后主线程继续接收客户端 Y 的请求. 客户端一侧也可以使用一个子线程和服务器端进行通信.这样客户端主线程 ...

  6. Batch Norm、Layer Norm、Weight Norm与SELU

    加速网络收敛——BN.LN.WN与selu 自Batch Norm出现之后,Layer Norm和Weight Norm作为Batch Norm的变体相继出现.最近又出来一个很”简单”的激活函数Sel ...

  7. Reset GitLab Root Password

    重置gitlab管理员密码 Log into your server with root privileges. Then start a Ruby on Rails console. Start t ...

  8. PHP isset()与empty()的使用区别

    PHP的isset()函数 一般用来检测变量是否设置 格式:bool isset ( mixed var [, mixed var [, ...]] ) 功能:检测变量是否设置 返回值: 若变量不存在 ...

  9. Ubuntu添加源列表

    1.首先备份源列表:sudo cp /etc/apt/sources.list /etc/apt/sources.list_backup 2.清空原来的/etc/apt/sources.list,添加 ...

  10. maven Could not find artifact com.** 无法下载原因分析

    1.有时候经常莫名其妙的遇到这个问题:比如在idea重新导入一个新项目,或者在原来的空间里面引入一个新项目.去私服里面查看明明是有的,但是就是下载不下来. 结合网上搜的和自己遇到的,总结原因如下: 1 ...