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

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. 谷歌旗下专业图片编辑Snapseed获重大更新

    谷歌旗下的图片编辑应用Snapseed今天获得重大更新,承诺为用户的手机或者平板带来“精确和卓越控制的专业图片编辑软件”.Android和iOS版本同时获得更新,新增包括镜头模糊.色条对比.更加灵活的 ...

  2. sql count执行速度测试

    要对数据库里面的数据数量进行统计使用,数据库的大概有2000w多的数据.数据库是mysql5.6 用的是远程连接测试 ELECT COUNT(*) 执行语句: select count( *) fro ...

  3. Hystrix使用详解

    原文参考:http://hot66hot.iteye.com/blog/2155036 一:为什么需要Hystrix? 在大中型分布式系统中,通常系统很多依赖(HTTP,hession,Netty,D ...

  4. java 正则表达式(内附例子)

    前言:最近工作中遇到了大量用正则表达式的情况,需要用一定的规则匹配字符串,然后提取里面的数据,格式化后转成自己想要的格式.所以作为一个菜鸟是时候再来巩固一下正则表达式了.转载请注明出处:https:/ ...

  5. 列表 enumerat 解包, 针对索引和元素

    dic = [1,2,3,4,5] for a,b in enumerate(dic): print(a,b) # a就是索引 b是元素

  6. 使用AJAX实现分页

    Fenye.html <!DOCTYPE html> <html> <head> <title>分页</title> </head&g ...

  7. charles 抓包 https 证书

    1. 概述 环境:这里是windows8 和 android (参考了ios环境的博客) 手机app点击发出http及https的请求,之前抓包都有请求的相关内容展示,这次没有,原来之前的一直抓的是h ...

  8. ifconfig命令无法找到,提示bash: ifconfig: command not found

    问题就是题目那样,具体解决方法截图如下: 分析问题 1.whereis ifconfig 看一下这个命令在哪个目录下 2.echo $PATH 看一下该目录是否在路经下,注意lunux下是完全区分大小 ...

  9. Dynamics 365 App for Outlook 与 Dynamics 365 for Outlook(已被弃用)

    在最新的版本中Dynamics 365 for Outlook(Outlook 客户端)已被弃用 随 Dynamics CRM 2016(版本 8.0)引入的 Dynamics 365 App for ...

  10. CSS 几款比较常用的翻转特效

    第一个:360度翻转特效 <style>* { margin:0; padding:0; } .aa { width: 220px; height: 220px; margin: 0 au ...