POJ-2407-Relatives(欧拉函数模板题)
来源:互联网 发布:mysql 根据已有的函数 编辑:程序博客网 时间:2024/06/06 08:53
Description
Given n, a positive integer, how many positive integers less than n are relatively prime to n? Two integers a and b are relatively prime if there are no integers x > 1, y > 0, z > 0 such that a = xy and b = xz.
Input
There are several test cases. For each test case, standard input contains a line with n <= 1,000,000,000. A line containing 0 follows the last case.
Output
For each test case there should be single line of output answering the question posed above.
Sample Input
7
12
0
Sample Output
6
4
这是欧拉函数的模板题,不懂欧拉函数的话点这里http://blog.csdn.net/qq_38712932/article/details/76472505
#include <cstdio>typedef long long ll;ll oula(ll n){ ll rea=n; for(int i = 2; i * i <= n; i ++) { if(n%i==0) { rea=rea-rea/i; do n/=i; while(n%i==0); } } if(n>1) rea=rea-rea/n; return rea;}int main(){ ll n; while(~scanf("%lld",&n),n) printf("%lld\n",oula(n)); return 0;}
阅读全文
0 0
- POJ-2407-Relatives(欧拉函数模板题)
- poj 2407 Relatives(欧拉函数模板题)
- poj 2407 Relatives(欧拉函数模板)
- POJ 2407 Relatives && UVA 10299 Relatives(欧拉函数)
- poj 2407 Relatives(欧拉函数)
- POJ 2407 Relatives(欧拉函数)
- POJ 2407 Relatives(欧拉函数)
- POJ 2407 Relatives (欧拉函数)
- POJ 2407 Relatives(欧拉函数)
- 【POJ】2407 - Relatives(欧拉函数)
- POJ 2407 Relatives (欧拉函数)
- 欧拉函数 模板题 POJ2407 Relatives
- POJ 2407 Relatives 欧拉函数
- POJ 2407 Relatives 欧拉函数
- POJ 2407 Relatives 欧拉函数题解
- poj 2407Relatives(数论:欧拉函数)
- [POJ 2407]Relatives(欧拉函数)
- POJ 2407 Relatives (欧拉函数)
- 牢记25个最佳的SSH命令
- 实验吧keyboard
- python求解重叠区域线段覆盖总长度
- Ubuntu 16.0.4 Linux下安装Docker
- bootstrap轮播图与现实问题和active使用等
- POJ-2407-Relatives(欧拉函数模板题)
- 基于Unity3D 的Htc vive的基本交互
- 23种设计模式汇总整理
- 23. Merge k Sorted Lists
- Linux系统管理与设置
- sql语句行列转至
- 如何拥有赏(sao)心(de)悦(yi)目(bi)的开发环境
- 基本数据类型包装数据类型之间的转换
- 嵌入式软件的移植的一般步骤