POJ 2407
裸 的求欧拉函数
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std; int main(){
int n;
while(scanf("%d",&n),n){
int res=n;
int L=(int)sqrt(n*1.0);
// cout<<L<<endl;
for(int i=2;i<=L;i++){
if(n%i==0){
// cout<<i<<endl;
res=res-res/i;
while(n%i==0)
n/=i;
// cout<<n<<endl;
}
}
if(n>1)
res=res-res/n;
printf("%d\n",res);
}
return 0;
}
POJ 2407的更多相关文章
- POJ 2407 (欧拉函数)
题目链接: http://poj.org/problem?id=2407 题目大意:求小于n且与n互质的正整数个数. 解题思路: 欧拉函数=小于n且与n互质的正整数个数. 公式=n*(1-1/P1)* ...
- Poj(2407),Greater New York Regional 2015 (D)
题目链接:http://poj.org/problem?id=2407 Relatives Time Limit: 1000MS Memory Limit: 65536K Total Submis ...
- POJ 2407 Relatives(欧拉函数)
http://poj.org/problem?id=2407 题意: 给出一个n,求小于等于的n的数中与n互质的数有几个. 思路: 欧拉函数的作用就是用来求这个的. #include<iostr ...
- poj 2407 欧拉函数裸题
http://poj.org/problem?id=2407 题意:多组数据,每次输入一个数 ,求这个数的欧拉函数 int euler_phi(int n){//单个欧拉函数 int m=(int)s ...
- 数论 - 欧拉函数模板题 --- poj 2407 : Relatives
Relatives Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11372 Accepted: 5544 Descri ...
- POJ 2407 Relatives 【欧拉函数】
裸欧拉函数. #include<stdio.h> #include<string.h> ; int p[N],pr[N],cnt; void init(){ ;i<N;i ...
- POJ 2407 Relatives
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13920 Accepted: 6965 Description Give ...
- 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
#include <cstdio> #include <iostream> using namespace std; int phi(int x) { int t=x; ;i& ...
随机推荐
- VmBox硬盘容量调整
硬盘容量修改为15*1024MB. VBoxManage.exe modifyhd "F:\VirtualBox\magiclinux.vdi" --resize 15360 ...
- Spring配置之OpenSessionInViewFilter
转自:https://www.cnblogs.com/blogonfly/articles/3991782.html 参考: OpenSessionInViewFilter作用及配置:http://w ...
- php json 初始化函数(格式化json字符串为php json_decode 标准的字符串)
$json="[{ 'i':100000, 'u':-1,n: '中国'},{i:100001,u:-1,n:'阿尔巴尼亚'},{i:100002,u:-1,n:'阿尔及利亚',}]&quo ...
- 利用阿里云加速Docker For Windows
1.进入阿里云的容器镜像服务,找到镜像中心的镜像加速器. https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors 2.进入Docker ...
- 9.19[XJOI] NOIP训练37
上午[XJOI] NOIP训练37 T1 同余方程 Problem description 已知一个整数a,素数p,求解 $x^{2}\equiv a(mod p) $ 是否有整数解 Solution ...
- 4、Collection接口功能测试(所有的All方法)
package cn.itcast_01; import java.util.ArrayList; import java.util.Collection; /* * 所有带All的方法:(听完就忘) ...
- Hadoop MapReduce编程 API入门系列之wordcount版本1(五)
这个很简单哈,编程的版本很多种. 代码版本1 package zhouls.bigdata.myMapReduce.wordcount5; import java.io.IOException; im ...
- Shiro从数据表中初始化资源和权限
之前在测试的Web工程下,我们在applicationContext.xml中配置了shiroFilter资源拦截器信息: <bean id="shiroFilter" cl ...
- JS中常见问题
//s金额 n保留几位小数 默认保留两位小数 s代表金额,n代表保留的小数位数 function formatMoney(s, n) { n = n > 0 && n <= ...
- SDL2源代码分析
1:初始化(SDL_Init()) SDL简介 有关SDL的简介在<最简单的视音频播放示例7:SDL2播放RGB/YUV>以及<最简单的视音频播放示例9:SDL2播放PCM>中 ...