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

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. 使用google-gson类库解析json文件

    使用google-gson类库解析json文件 使用JsonParser解析器来解析字符串和输入流,变成json对象 代码如下: public class Readjson { public stat ...

  2. AE三维点击查询(3D Identify)的实现(转)

    AE三维点击查询(3D Identify)的实现,类似ArcGIS的Identify对话框/////////////////////////////////////////////////////// ...

  3. 【代码笔记】iOS-自动成表格的效果

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> #import "LabelOnBackImag ...

  4. css中的线及vertical-align

    行内元素格式化顺序: 相关概念:  leading(行间距):指填充在两行文字间的铅条,等于line-height 和 font-size之差,其中一半leading加到文字上方,另一半leading ...

  5. react知识点汇总

    ①uncontrolComponent & controlComponent If your form is incredibly simple in terms of UI feedback ...

  6. 读《锋利的jQuery》中first-child时的一个细节

    今天在看<锋利的jQuery>这书时,看到过滤选择器那一节.有个知识点引起了我的注意. (我不用书里一模一样的代码做例子)举个简单的例子-代码: <ul> <li> ...

  7. Dynamics 365 Customer Engagement 中对API的调整内容分享

    当前版本中弃用了以下客户端 API 以重新组织 Xrm 客户端 API 对象模型,从而更好地满足以下需求:使用同一客户端脚本而不必基于上下文或基于运行这些脚本的客户端(Web 客户端或新的统一接口)来 ...

  8. [转]Linux内核最新的连续内存分配器(CMA)——避免预留大块内存

    http://blog.csdn.net/21cnbao/article/details/7309757 在我们使用ARM等嵌入式Linux系统的时候,一个头疼的问题是GPU,Camera,HDMI等 ...

  9. Dialog向Activity传递数据

    PopupDialog中声明一个内部接口PriorityListener,接口中声明一个回调函数refreshPriorityUI,用于在 Dialog的监听事件触发后刷新Activity的UI显示. ...

  10. python中的字符串编码问题——2.理解ASCII码、ANSI码、Unicode编码、UTF-8编码

    ASCII码:全名是American Standard Code for Information Interchange,ASCII码中,一个英文字母(不分大小写)占一个字节的空间,范围0x00~0x ...