POJ 2407 Relatives
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 13920 | Accepted: 6965 |
Description
Input
Output
Sample Input
7
12
0
Sample Output
6
4
Source
#include<cstdio>
int euler_phi(int p){
int phi=p;
for(int i=;i*i<=p;i++){
if(!(p%i)){
phi=phi-phi/i;
while(!(p%i))
p/=i;
}
}
if(p>)
phi=phi-phi/p;
return phi;
}
int main(){
int p;
while(scanf("%d",&p),p)
printf("%d\n",euler_phi(p));
return ;
}
裸的欧拉函数
POJ 2407 Relatives的更多相关文章
- POJ 2407 Relatives(欧拉函数)
http://poj.org/problem?id=2407 题意: 给出一个n,求小于等于的n的数中与n互质的数有几个. 思路: 欧拉函数的作用就是用来求这个的. #include<iostr ...
- 数论 - 欧拉函数模板题 --- poj 2407 : Relatives
Relatives Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11372 Accepted: 5544 Descri ...
- POJ 2407 Relatives(欧拉函数入门题)
Relatives Given n, a positive integer, how many positive integers less than n are relatively prime t ...
- POJ 2407 Relatives 【欧拉函数】
裸欧拉函数. #include<stdio.h> #include<string.h> ; int p[N],pr[N],cnt; void init(){ ;i<N;i ...
- POJ 2407 Relatives(欧拉函数)
题目链接 题意 : 求小于等于n中与n互质的数的个数. 思路 : 看数学的时候有一部分是将欧拉函数的,虽然我没怎么看懂,但是模板我记得了,所以直接套了一下模板. 这里是欧拉函数的简介. #includ ...
- poj 2407 Relatives(简单欧拉函数)
Description Given n, a positive integer, how many positive integers less than n are relatively prime ...
- POJ 2407 Relatives (欧拉函数)
题目链接 Description Given n, a positive integer, how many positive integers less than n are relatively ...
- POJ 2407 Relatives【欧拉函数】
<题目链接> 题目大意: Given n, a positive integer, how many positive integers less than n are relativel ...
- POJ 2407 Relatives 欧拉函数题解
版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/,未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...
随机推荐
- 在Shell中使用函数文件
需要编写一个较庞大的脚本时,可能会涉及许多函数.变量.这是通常建议将众多的函数.变量放入一个单独的脚本内.这样做的好处很明显,不用担心某个函数.变量是否已经被定义和使用,也不用频繁地定义.清除函数和变 ...
- linux下的十六进制编辑器---wxHexEdit
....其实wxHexEdit是一个跨平台的十六进制编辑器,支持windows,linux,mac. 之所以标题用linux...是因为windows下多数都用winhex,UE之类的编辑器,而lin ...
- Feister network
在密码学中,Feister network(又叫Feister Function, 一下简称 F函数)是一种用在块加密上的对称结构,很多种块加密算法都是使用这种结构. 优点: 1.加解密的过程非常相似 ...
- 加密数据的填充方式(Padding)
1.填充数据为填充字节的长度 这种填充方式中,填充字符串由一个字节序列组成,每个字节填充该字节序列的长度.假定块长度为8,原文数据长度9,则填充字节数等于0x07:如果明文数据长度为8的整数倍,则填充 ...
- Fedora 23如何安装LAMP服务器
LAMP 是开源系统上 Web 服务器的梦幻组合.LAMP 是 Linux. Apache HTTP 服务. MySQL/MariaDB 数据库和 PHP. Perl 或 Python 的简称. 下面 ...
- fir.im Weekly - 2016 移动开发技术大回顾
2016 年是移动技术发展迅速的一年,认认真真回顾这一年必不可少.@移动开发前线 的 这篇 2016移动开发技术巡礼 ,精心盘点了 2016 年 移动开发技术大事件,分为 iOS/Android平台篇 ...
- archlinux随记
xrdb -merge .Xresources才能使urxvt的配色显示正常 xpmroot 包含在fvwm包中
- 10 ways to be a faster code reviewer--reference
reference:http://blog.codacy.com/top-10-faster-code-reviews/ This is a blog post of our Code Reading ...
- Qt 静态编译的问题.
编译参数 configure -confirm-license -opensource -developer-build -static -prefix D:\libraries\Qt5.3.1s - ...
- Android自定义控件:进度条的四种实现方式(Progress Wheel的解析)
最近一直在学习自定义控件,搜了许多大牛们Blog里分享的小教程,也上GitHub找了一些类似的控件进行学习.发现读起来都不太好懂,就想写这么一篇东西作为学习笔记吧. 一.控件介绍: 进度条在App中非 ...