hdu 2654(欧拉函数)
Become A Hero
Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 210 Accepted Submission(s): 57
wants to be a hero since he was a child. Recently he is reading a book
called “Where Is Hero From” written by ZTY. After reading the book,
Lemon sends a letter to ZTY. Soon he recieves a reply.
Dear Lemon,
It is my way of success. Please caculate the algorithm, and secret is behind the answer. The algorithm follows:
Int Answer(Int n)
{
.......Count = 0;
.......For (I = 1; I <= n; I++)
.......{
..............If (LCM(I, n) < n * I)
....................Count++;
.......}
.......Return Count;
}
The LCM(m, n) is the lowest common multiple of m and n.
It is easy for you, isn’t it.
Please hurry up!
ZTY
What a good chance to be a hero. Lemon can not wait any longer. Please help Lemon get the answer as soon as possible.
line contains an integer T(1 <= T <= 1000000) indicates the
number of test case. Then T line follows, each line contains an integer n
(1 <= n <= 2000000).
1
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
typedef long long LL;
const int N = ;
int euler[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-);
}
}
} int main()
{
getEuler();
int tcase;
scanf("%d",&tcase);
while(tcase--){
int n;
scanf("%d",&n);
printf("%d\n",n-euler[n]);
}
return ;
}
hdu 2654(欧拉函数)的更多相关文章
- hdu 6390 欧拉函数+容斥(莫比乌斯函数) GuGuFishtion
http://acm.hdu.edu.cn/showproblem.php?pid=6390 题意:求一个式子 题解:看题解,写代码 第一行就看不出来,后面的sigma公式也不会化简.mobius也不 ...
- hdu 2824(欧拉函数)
The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- 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 2824 欧拉函数 O(nlogn) 和O(n)
裸题 O(nlogn): #include <cstdio> #include <iostream> #include <algorithm> using name ...
- 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是 ...
- hdu 1787(欧拉函数)
GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
随机推荐
- Django--源码安装
1.安装setuptools cd /usr/src tar zxf setuptools-18.3.2.tar.gz cd setuptools-18.3.2/ python setup.py bu ...
- Python 频繁请求问题: [Errno 104] Connection reset by peer
Table of Contents 1. 记遇到的一个问题:[Errno 104] Connection reset by peer 记遇到的一个问题:[Errno 104] Connection r ...
- StartWith 测试
var clientConfiguration = GetConfiguration("couchbase.json"); ClusterHelper.Initialize(cli ...
- IOS开发---菜鸟学习之路--(一)
PS(废话): 看了那么多的博客文章,发现大部分人都一直在强调写技术博客的重要性,索性自己也耐着性子写写看吧. 写博客的重要性之类的说明,我就不做复制黏贴的工作了.因为自己没有写过多少,所也不清楚是不 ...
- 【Set Matrix Zeros】cpp
题目: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. cl ...
- BugKu-妹子的陌陌
打开后看这张图片,先放winhex里面,文件头FFD8,是jpg图片.看文件尾并不是FFD9,所以binwalk分析一下. 发现有一个rar文件,然后用foremost分离.发现里面有个加密的rar文 ...
- 拼多多2018校招编程题汇总 Python实现
题目原址 列表补全 在商城的某个位置有一个商品列表,该列表是由L1.L2两个子列表拼接而成.当用户浏览并翻页时,需要从列表L1.L2中获取商品进行展示.展示规则如下: 用户可以进行多次翻页,用offs ...
- Linux性能分析调优工具介绍
1.常用性能分析工具 1)CPU性能分析工具 vmstat ps sar time strace pstree top 2)Memory性能分析工具 vmstat strace top ipcs ip ...
- bzoj 4131: 并行博弈 (parallel)
bzoj 4131: 并行博弈 (parallel) Description lyp和ld在一个n*m的棋盘上玩翻转棋,游戏棋盘坐标假设为(x, y),1 ≤ x ≤ n,1 ≤ y ≤ m,这个游戏 ...
- markdown的使用说明
markdown 你很牛 说点废话 背景 md 经常喜欢写点东西的人,是不是觉得用各种笔记软件或者是html,排版总是让你感到蛋蛋的忧伤,本来满腹经纶,最后由于不好排版,阅读体验差,最后...but. ...