Relatives
Description
Input
Output
Sample Input
7
12
0
Sample Output
6
4
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using namespace std;
typedef long long LL ;
int euler(int n){ //返回euler(n)
int res=n,a=n;
for(int i=2;i*i<=a;i++){
if(a%i==0){
res=res/i*(i-1);//先进行除法是为了防止中间数据的溢出
while(a%i==0) a/=i;
}
}
if(a>1) res=res/a*(a-1);
return res;
} int main (){
int x;
while(~scanf("%d",&x)&&x){
printf("%d\n",euler(x));
}
return 0;
}
Relatives的更多相关文章
- 数论 - 欧拉函数模板题 --- 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(欧拉函数模板)
Relatives AC代码 Relatives Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16186 Accept ...
- Text Relatives II
[Text Relatives II] When your app determines that the user has requested the edit menu—which could b ...
- Text Relatives
[Text Relatives] With TextKit the resources at your disposal range from framework objects—such as te ...
- God made relatives.Thank God we can choose our friends.
God made relatives.Thank God we can choose our friends. 神决定了谁是你的亲戚, 幸运的是在选择朋友方面他给了你留了余地
- POJ 2021 Relative Relatives
Relative Relatives Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3339 Accepted: 146 ...
- Relatives(容斥)
Relatives Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 15708 Accepted: 7966 Descri ...
- POJ 2407 Relatives 【欧拉函数】
裸欧拉函数. #include<stdio.h> #include<string.h> ; int p[N],pr[N],cnt; void init(){ ;i<N;i ...
随机推荐
- redis教程
windows下安装redis: http://jingyan.baidu.com/article/49ad8bce40174f5834d8fa24.html redis教程: http://www. ...
- 转: 我们为什么使用ORM?
博客园在推广ORM方面的确做了很大的贡献,很多的程序员开始使用ORM,不用写SQL的喜悦让他们激动不已,可是好景不长,他们很快发现众多的烦恼一个接一个的出现了. 很遗憾,我并不打算在这篇文章中解决这些 ...
- springmvc学习第一天
一.helloworld的实现 1.加入jar包(加入无关的jar包可能会引起服务器的冲突) commons-logging-1.2.jarjstl.jarspring-aop-4.1.6.RELEA ...
- Debugging Process Startup
Debugging Process Startup Q: How do I debug a process's startup code? A: This depends on how the pr ...
- PHP操作Excel – PHPExcel 基本用法详解
导出excel属性设置//Include classrequire_once('Classes/PHPExcel.php');require_once('Classes/PHPExcel/Writer ...
- spring整合hibernate配置文件
Spring对hibernate配置文件hibernate.cfg.xml的集成,来取代hibernate.cfg.xml的配置 spring对hibernate配置文件hibernate.cfg.x ...
- select、poll、poll的比较(转)
原文地址:http://www.cnblogs.com/xuxm2007/archive/2011/08/15/2139809.html select.poll.epoll的比较 linux提供了se ...
- Recyclerview使用系列教材
Recylerview越来越多的人使用,本人录制了一套课程,欢迎大家观看,录制的比较仓促,第一课讲解的课程目录有点问题,请大家谅解,目录请看视频外该课程介绍的内容即可. 该课程付费课程包含: 1-Re ...
- python 列表操作
列表的基本操作示例展示: append 功能:列表追加元素 name = ['sd','dfdf','drer'] name.append('sdsd') 返回结果:name ['sd', 'dfdf ...
- locate无法open mlocate.db
# locate xxxx locate: can not open () `/var/lib/mlocate/mlocate.db': No such file or directory 如果出现此 ...