hdu 2824(欧拉函数)
The Euler function
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5235 Accepted Submission(s): 2225
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)
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
typedef long long LL;
const int N =;
LL euler[N];
//LL sum[N];
void getEuler()
{
memset(euler,,sizeof(euler));
euler[] = ;
for(int i = ; i <= N; i++){
if(!euler[i])
for(int j = i; j <= N; j+= i)
{
if(!euler[j])
euler[j] = j;
euler[j] = euler[j]/i*(i-);
}
//sum[i]=sum[i-1]+(LL)euler[i];
}
} int main()
{
getEuler();
int a,b;
while(~scanf("%d%d",&a,&b)){
LL sum = ;
for(int i=a;i<=b;i++){
sum+=euler[i];
}
printf("%lld\n",sum);
}
return ;
}
hdu 2824(欧拉函数)的更多相关文章
- hdu 2824 欧拉函数 O(nlogn) 和O(n)
裸题 O(nlogn): #include <cstdio> #include <iostream> #include <algorithm> using name ...
- hdu 6390 欧拉函数+容斥(莫比乌斯函数) GuGuFishtion
http://acm.hdu.edu.cn/showproblem.php?pid=6390 题意:求一个式子 题解:看题解,写代码 第一行就看不出来,后面的sigma公式也不会化简.mobius也不 ...
- hdu 2654(欧拉函数)
Become A Hero Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hdu 1395(欧拉函数)
2^x mod n = 1 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- hdu 3307(欧拉函数+好题)
Description has only two Sentences Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/327 ...
- 找新朋友 HDU - 1286 欧拉函数模板题
题意: 求出来区间[1,n]内与n互质的数的数量 题解: 典型的欧拉函数应用,具体见这里:Relatives POJ - 2407 欧拉函数 代码: 1 #include<stdio.h> ...
- *HDU 1286,2824欧拉函数
#include<iostream> #include<string> #include<cstdio> #include<cmath> #includ ...
- hdu 4983 欧拉函数
http://acm.hdu.edu.cn/showproblem.php?pid=4983 求有多少对元组满足题目中的公式. 对于K=1的情况,等价于gcd(A, N) * gcd(B, N) = ...
- hdu 4002 欧拉函数 2011大连赛区网络赛B
题意:求1-n内最大的x/phi(x) 通式:φ(x)=x*(1-1/p1)*(1-1/p2)*(1-1/p3)*(1-1/p4)…..(1-1/pn),其中p1, p2……pn为x的所有质因数,x是 ...
随机推荐
- 有三个线程T1 T2 T3,如何保证他们按顺序执行
T3先执行,在T3的run中,调用t2.join,让t2执行完成后再执行t3 在T2的run中,调用t1.join,让t1执行完成后再让T2执行 public class JoinTest { ...
- java十分钟速懂知识点——引用
一.由健忘症引起的问题 今天闲来没事在日志中瞟见了个OutOfMemoryError错误,不由得想到前一段时间看到一篇面经里问到Java中是否有内存泄露,这个很久以前是留意过的,大体记得内存溢出和内存 ...
- python中pip 出错
错误:error in launcher: Unable to create process using '" python多个版本时出现, 解决方法-- 将pip重新安装 python3 ...
- [译]Exactly once is NOT exactly the same
近日学习Pulsar文档时,注意到Pulsar提到其提供的是effectively-once语义,而不是其它流计算引擎announce的exactly-once语义,并引用了Exactly once ...
- 连续小波变换(CWT)
整理下时频分析变换的方法,遇见好的文章就记录下来了,本篇博客参考知乎https://www.zhihu.com/topic/19621077/top-answers上的一个回答,自己手敲一遍,增强记忆 ...
- laravel5.2总结--数据填充
1 生成一个seeder文件 你可以通过 make:seeder artisan命令来生成一个 Seeder.所有通过框架生成的 Seeder 都将被放置在 database/seeds 路径: ...
- leetcode 【 Remove Element 】python 实现
题目: Given an array and a value, remove all instances of that value in place and return the new lengt ...
- selenium webdriver——鼠标事件
Web产品中提供了丰富的鼠标交互方式,例如鼠标右击.双击.悬停.甚至是鼠标拖动等功能,在WebDriver中,将这些关于鼠标操作的方法 封装在ActionChains类中: ActionChains类 ...
- mysql event 学习
mysql 通过事件可以实现定时任务 : 1. 检查你的MYSQL是否开了这个功能 show variables like "%scheduler" //注意 最后是er 2. ...
- 谈谈Python中元类Metaclass(二):ORM实践
什么是ORM? ORM的英文全称是“Object Relational Mapping”,即对象-关系映射,从字面上直接理解,就是把“关系”给“对象”化. 对应到数据库,我们知道关系数据库(例如Mys ...