http://acm.hdu.edu.cn/showproblem.php?pid=2824

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7752    Accepted Submission(s): 3217

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
 
 
欧拉函数表。前缀和
 #include <algorithm>
#include <cstdio> using namespace std; #define LL long long
const int N();
LL a,b,phi[N]; void All_phi()
{
for(int i=;i<=N;i++)
phi[i]=i;
for(int i=;i<=N;i++)
if(phi[i]==i)
for(int j=i;j<=N;j+=i)
phi[j]=phi[j]/i*(i-);
} int main()
{
All_phi();
for(int i=;i<=N+;i++) phi[i]=phi[i-]+phi[i];
for(;scanf("%d%d",&a,&b)!=EOF;)
printf("%I64d\n",phi[b]-phi[a-]);
return ;
}

HDU——T 2824 The Euler function的更多相关文章

  1. 欧拉函数 & 【POJ】2478 Farey Sequence & 【HDU】2824 The Euler function

    http://poj.org/problem?id=2478 http://acm.hdu.edu.cn/showproblem.php?pid=2824 欧拉函数模板裸题,有两种方法求出所有的欧拉函 ...

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

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

  3. hdu 2824 The Euler function

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

  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 --------欧拉模板

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

  6. HDU——2824 The Euler function

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

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

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

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

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

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

    如果打表的话会超内存,我想到了一种方法解决这个问题.题目给出的数据时3000000,我将三百万分成300个数据,将整万的数据存储下来,计算的时候,先计算x和y之间整万的数据,然后再计算零散数据. 想法 ...

随机推荐

  1. win7防火墙里开启端口的图文教程

    转载于:http://www.cnblogs.com/vipsoft/archive/2012/05/02/2478847.html 开启端口:打开“控制面板”中的“Windows防火墙”,点击左侧的 ...

  2. double和decimal的ToString("#.##")方法使用的是四舍五入;

    顺带提一下: 1. double和decimal的ToString("#.##")方法使用的是四舍五入: 2. 静态类System.Math下的Round(decimal d, i ...

  3. vue-router学习例子分享

    http://blog.csdn.net/bboyjoe/article/details/52804988 <!DOCTYPE html> <html lang="en&q ...

  4. Linux常用PDF阅读软件

    1.福昕阅读器是一款PDF文档阅读器,对中文的支持度非常高.福昕阅读器作为全球最流行的PDF阅读器,能够快速打开.浏览.审阅.注释.签署及打印任何PDF文件. 2.evince是一个支持多种格式的文件 ...

  5. 洛谷 P2913 [USACO08OCT]车轮旋转Wheel Rotation

    P2913 [USACO08OCT]车轮旋转Wheel Rotation 题目描述 Farmer John has an old-time thresher (wheat harvester) tha ...

  6. Starting nagios:This account is currently not available.

    解决方式: 又一次安装php 再重新启动apache 再启动nagios 再訪问:http://ip/nagios 我的问题就是 解决的.

  7. 【数字图像处理】五.MFC图像点运算之灰度线性变化、灰度非线性变化、阈值化和均衡化处理具体解释

    本文主要讲述基于VC++6.0 MFC图像处理的应用知识,主要结合自己大三所学课程<数字图像处理>及课件进行解说.主要通过MFC单文档视图实现显示BMP图片点运算处理.包含图像灰度线性变换 ...

  8. RadioButton的check改变的时候

    https://stackoverflow.com/questions/8095256/asp-net-radio-button-change You'll need to specify the a ...

  9. virtual与override

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  10. 数据库事务及其EF中如何处理事务

    一.基础知识 1)         使用事务级别ReadUnCommited 会产生脏读现像,意味着读取到的为UnCommited(未提交)的数据.怎么理解呢?在使用该隔离级别的事务开始后.更新了数据 ...