感觉自己弱爆了,做做SGU吧。。。

#include<iostream>
#include<cmath> //欧拉函数
using namespace std;
int euler(int n)
{
int m=n; int ans=n;
for(int i=2;i<=sqrt(n*1.0);i++) //注意等于号,
{
if(m%i==0)
{
ans=ans*(i-1)*1.0/i;
while(m%i==0)m/=i;
}
}
if(m!=1)ans=ans*(m-1)/m;
return ans;
}
int main()
{
int n;
while(cin>>n)
{
cout<<euler(n)<<endl;
}
}

sgu 102模拟欧拉函数的更多相关文章

  1. NOIP模拟:切蛋糕(数学欧拉函数)

    题目描述  BG 有一块细长的蛋糕,长度为 n. 有一些人要来 BG 家里吃蛋糕, BG 把蛋糕切成了若干块(整数长度),然后分给这些人. 为了公平,每个人得到的蛋糕长度和必须相等,且必须是连续的一段 ...

  2. poj2478 Farey Sequence (欧拉函数)

    Farey Sequence 题意:给定一个数n,求在[1,n]这个范围内两两互质的数的个数.(转化为给定一个数n,比n小且与n互质的数的个数) 知识点: 欧拉函数: 普通求法: int Euler( ...

  3. UVA12493 - Stars(求1-N与N互质的个数)欧拉函数

    Sample Input 3 4 5 18 36 360 2147483647 Sample Output 1 1 2 3 6 48 1073741823 题目链接:https://uva.onlin ...

  4. 快速切题 sgu102.Coprimes 欧拉函数 模板程度 难度:0

    102. Coprimes time limit per test: 0.25 sec. memory limit per test: 4096 KB For given integer N (1&l ...

  5. hdu2588 GCD (欧拉函数)

    GCD 题意:输入N,M(2<=N<=1000000000, 1<=M<=N), 设1<=X<=N,求使gcd(X,N)>=M的X的个数.  (文末有题) 知 ...

  6. BZOJ 2705: [SDOI2012]Longge的问题 [欧拉函数]

    2705: [SDOI2012]Longge的问题 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 2553  Solved: 1565[Submit][ ...

  7. BZOJ 2818: Gcd [欧拉函数 质数 线性筛]【学习笔记】

    2818: Gcd Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 4436  Solved: 1957[Submit][Status][Discuss ...

  8. COGS2531. [HZOI 2016]函数的美 打表+欧拉函数

    题目:http://cogs.pw/cogs/problem/problem.php?pid=2533 这道题考察打表观察规律. 发现对f的定义实际是递归式的 f(n,k) = f(0,f(n-1,k ...

  9. 51Nod-1136 欧拉函数

    51Nod: http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1136 1136 欧拉函数 基准时间限制:1 秒 空间限制: ...

随机推荐

  1. pb2.text_format.Merge(f.read(), self.solver_param) AttributeError: 'module' object has no attribute 'text_format'

    http://blog.csdn.net/qq_33202928/article/details/72526710

  2. linux_1

    注: 创建软连接: "ln -s xxx 路径1" 在路径1创建xxx的软连接 特点: 1.文件类型 l 2.相当于windows的快捷方式 创建硬链接: "ln xxx ...

  3. JavaScript中数据类型和typeof返回的数据类型

    除了上图,要注意三点:1.symbol是ES6中新增的数据类型 2.typeof(null)结果是Object 3.typeof(Object)和typeof(Array)的结果是function,因 ...

  4. glove 安装错误

    https://stackoverflow.com/questions/44921611/error-installing-glove-python-link-exe-failed-with-exit ...

  5. shell脚本,awk 匹配的做修改后打印,不匹配的打印。

    文件file内容如下a 1a 2b 3b 4 b 5c 6c 7 要求:第一列匹配b时,如果第二列大于3,那么将第二列加上1后打印,其余的原封不动打印.结果如下: a 1a 2b 3b 5 b 6c ...

  6. visibilitychange 标签可见性

    var pageVisibility = document.visibilityState;// 监听 visibility change 事件document.addEventListener('v ...

  7. Linux基础学习-Docker学习笔记

    Docker安装 1 官方网站访问速度很慢,帮助文档 2 国内中文网站,帮助文档 [root@qdlinux ~]# yum remove docker \ docker-client \ docke ...

  8. RN踩坑

    使用夜神 使用夜神作为模拟器,这个模拟器启动就会监听62001端口. 开发工具与模拟器的通信都是通过adb.夜神模拟器的安装目录/bin下有一个adb.exe,android sdk tools下也有 ...

  9. 条款52:写了placement new 也要写placement delete(write placement delete if you write placement new)

    NOTE: 1.当你写一个placement operator new .请确定也要写出了对应的placement operator delete.如果没有这样做,你的程序可能发生隐晦而时断时续的内存 ...

  10. Linux中的定时任务简单操作实例

    今天,我怀着一颗感恩的心,写了一个小小的定时任务,细想还是写个简单的例子吧,希望能帮到你! 首先我在/usr/local/文件夹下创建了一个文件,hah.sh文件 在hah.sh里面编写shell脚本 ...