poj2407(欧拉函数-套模板)
来源:互联网 发布:剑三萝莉脸型数据 2016 编辑:程序博客网 时间:2024/05/17 03:13
http://poj.org/problem?id=2407
Relatives
Time Limit: 1000MSMemory Limit: 65536KTotal Submissions: 9323Accepted: 4398
Description
Given n, a positiveinteger, how many positive integers less than n are relativelyprime to n? Two integers a and b are relatively prime if there areno integers x > 1, y > 0, z > 0 such that a = xy and b =xz.
Input
There are severaltest cases. For each test case, standard input contains a line withn <= 1,000,000,000. A line containing 0 follows the lastcase.
Output
For each test casethere should be single line of output answering the question posedabove.
Sample Input
7120
Sample Output
64
Source
Waterloo local 2002.07.01
题意:就是求小于n且与n互质的数的个数
明显的欧拉函数直接套的模版。。(ps:自己专用模版)
#include
#include
#include
using namespace std;
int n;
int gcd(int a,int b)
{
returnb?gcd(b,a%b):a;
}
inline int lcm(int a,int b)
{
returna/gcd(a,b)*b;
}
int eular(int n)
{
intret=1,i;
for(i=2;i*i<=n;i++)
{
if(n%i==0)
{
n/=i;
ret*=i-1;
while(n%i==0)
{
n/=i;
ret*=i;
}
}
}
if(n>1)
{
ret*=n-1;
}
returnret;
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
if(n==0)
{
break;
}
printf("%d\n",eular(n));
}
return0;
}
#include
#include
using namespace std;
int n;
int gcd(int a,int b)
{
}
inline int lcm(int a,int b)
{
}
int eular(int n)
{
}
int main()
{
}
- poj2407(欧拉函数-套模板)
- poj2407欧拉函数模板
- 欧拉函数 模板题 POJ2407 Relatives
- POJ2407 Relatives 【欧拉函数模板】
- poj2407 欧拉函数
- POJ2407 欧拉函数
- POJ2407:Relatives(欧拉函数)
- POJ2407 Relatives(欧拉函数)
- poj2407 Farey Sequence 欧拉函数
- poj2407 Relatives 欧拉函数基本应用
- poj2407欧拉函数基础题
- [POJ2407]欧拉函数的值
- Relatives(poj2407)(求大数的欧拉函数模板题)
- poj2407欧拉
- 【欧拉函数】 poj2407 Relatives(裸欧拉函数)
- POJ2407---Relatives(求单个数的欧拉函数)
- POJ2407-Relatives(欧拉函数裸题)
- 板子题poj2407 欧拉函数 Java实现
- zoj1316(数学)
- poj2696(mod 数学上的定义)
- poj3372(完全剩余系(不会证))
- poj1730(数学)
- ios 本地化 多国语言处理
- poj2407(欧拉函数-套模板)
- poj2853(数学)
- poj2601(变形的等差数列求单项)
- poj1142(质因数分解)
- poj3090(eular)
- hdu2063(最大匹配--模版题)
- poj1469(最大匹配)
- poj3041(最小顶点覆盖)
- poj1325(最小顶点覆盖)