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 ...
随机推荐
- 一个 11 行 Python 代码实现的神经网络
一个 11 行 Python 代码实现的神经网络 2015/12/02 · 实践项目 · 15 评论· 神经网络 分享到:18 本文由 伯乐在线 - 耶鲁怕冷 翻译,Namco 校稿.未经许可,禁止转 ...
- Android GridView的使用
Android的GridView控件用于把一系列的空间组织成一个二维的网格显示出来应用的比较多的就是组合图片显示下面我就详细讲一个例子 首先写一个类继承BaseAdapter 1. Java代码 1 ...
- Android启动模式(三种)
1,标准启动模式 通过任务栈,每点一次button,将每一个实例都压入,然后点返回键时候,就弹出之前压入的实例. 每一次的地址都是不同的 测试代码:通过创建一个button和textView来显示本身 ...
- maven .assembly
配置文件中 配置好Assemblyc插件. 功能:打依赖jar包. java代码如下: <assembly xmlns="http://maven.apache.org/plugins ...
- JQuery源码解析(十)
默认回调对象设计 不传入任何参数,调用add的时候将函数add到内部的list中,调用fire的时候顺序触发list中的回调函数: function fn1(val) { console.log('f ...
- CI框架引入外部css和js文件
首先在项目根目录下建立assets文件夹,在这个文件夹下再建立css和js文件夹分别放置css和js文件 然后,在项目根目录下建立.htaccess文件 内容如下: RewriteEngine on ...
- python import eventlet包时提示ImportError: cannot import name eventlet
root@zte-desktop:/home/ubuntu/python-threads# cat eventlet.py #!/usr/bin python import eventlet from ...
- centos7 查询jdk安装路径
- main函数的简介
//// main函数的简介.h// IOS笔记//// Created by .// Copyright © 2015年 All rights reserved.// //#import ...
- Linux 安装 node
在 Linux 上安装 node,使用 Linux 编译后的版本最佳. 1.进入 node 官网,找到 Linux 版本下载,这里我们右键复制下载地址即可. 2.在 Linux 上,使用命令 curl ...