The Euler function

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

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
 
Recommend
 
欧拉函数....
代码:
 #include<stdio.h>
#include<string.h>
const int maxn=;
__int64 phi[maxn];
int main()
{
int st,en,i,j;
for(i=;i<maxn;i++)
phi[i]=i;
for(i=;i<maxn;i+=)
phi[i]/=;
for(i=;i<maxn;i+=)
{
if(phi[i]==i)
{
for(j=i;j<maxn;j+=i)
{
phi[j]=phi[j]/i*(i-); /*from left to right*/
}
}
}
while(scanf("%d%d",&st,&en)!=EOF)
{ __int64 ans=;
for(i=st;i<=en;i++)
{
ans+=phi[i];
}
printf("%I64d\n",ans);
} return ;
}

HDUOJ-----2824The Euler function的更多相关文章

  1. hdu 2824The Euler function

    题目链接 快速求出a到b之间所有数的欧拉函数. 一个一个求肯定是不行的, 我们知道欧拉函数的公式为phi(n) = n*(1-1/i1)*(1-1/i2).......i1, i2为素因子. 那么我们 ...

  2. The Euler function[HDU2824]

    The Euler functionTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...

  3. hdu 2824 The Euler function

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

  4. The Euler function(欧拉函数)

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

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

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

  6. The Euler function(线性筛欧拉函数)

    /* 题意:(n)表示小于n与n互质的数有多少个,给你两个数a,b让你计算a+(a+1)+(a+2)+......+b; 初步思路:暴力搞一下,打表 #放弃:打了十几分钟没打完 #改进:欧拉函数:具体 ...

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

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

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

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

  9. hdu2824 The Euler function(欧拉函数个数)

    版权声明:本文为博主原创文章,未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/36426357 题目链接:h ...

随机推荐

  1. Windows Server 2003 下实现网络负载均衡(2) (转)

    四.测试 在第一台机器上,关闭网络负载平衡管理器后,用鼠标右键单击“网络负载平衡群集”,从出现的菜单中选择“连接到现存的”,将会弹出“连接”界面.输入第一台计算机的名称或IP地址,点击“连接”按钮,在 ...

  2. [Git ] Git 使用规范流程

    reference : http://www.ruanyifeng.com/blog/2015/08/git-use-process.html 团队开发中,遵循一个合理.清晰的Git使用流程,是非常重 ...

  3. Gson全解析(下)-Gson性能分析

    前言 在之前的学习中,我们在Gson全解析(上)Gson使用的基础到分别运用了JsonSerializer和JsonDeserializer进行JSON和java实体类之间的相互转化. 在Gson全解 ...

  4. 第六章 memcached剖析

    注:本篇博客参考于两本书. <memcached全面剖析>,该书籍市面上应该没有,我传到了百度云盘,链接如下:http://pan.baidu.com/s/1qX00Lti <大型网 ...

  5. UNIX 域套接字——UNIX domain socket

    /*********************程序相关信息********************* * 程序编号:015 * 程序编写起始日期:2013.11.30 * 程序编写完成日期:2013.1 ...

  6. Web项目添加Maven支持

    很多时候,进入到某个项目组,并非项目刚刚开始:同样,很多时候,项目并非一开始就有Maven支持: 对现有的项目支持Maven,需要修改以下地方: 1. 将以下代码拷贝到工程根路径下的  .projec ...

  7. c#递归生成XML

    递归方法大家应该都很熟悉了,简而言之就是方法内部调用自己,就这样不断重复重复再重复的执行, 不过要担心死循环哟... 当我们系统需要动态生成菜单时,也就是说我们系统的菜单是存在数据库中的,数据库结构类 ...

  8. 【HBase】学习笔记

    HBASE 1 简介 1.1 官网 1.1.1 http://hbase.apache.org/ 1.1.2 Apache HBase™ is the Hadoop database, a distr ...

  9. 【Python】Django删除数据迁移记录

    find . -path "*migrations*" -name "*.py" -not -path "*__init__*" -exec ...

  10. PreferenceScreen的应用

    PreferenceScreen preference是偏好.首选的意思,PreferenceScreen个人翻译成 "偏好显示",明确这个意思就好.就是说依据特点灵活的定义显示内 ...