POJ 1284 Primitive Roots
来源:互联网 发布:湖南勇胜篮球数据 编辑:程序博客网 时间:2024/05/29 16:02
Primitive Roots
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 4062 Accepted: 2420
Description
We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if the set { (xi mod p) | 1 <= i <= p-1 } is equal to { 1, ..., p-1 }. For example, the consecutive powers of 3 modulo 7 are 3, 2, 6, 4, 5, 1, and thus 3 is a primitive root modulo 7.
Write a program which given any odd prime 3 <= p < 65536 outputs the number of primitive roots modulo p.
Write a program which given any odd prime 3 <= p < 65536 outputs the number of primitive roots modulo p.
Input
Each line of the input contains an odd prime numbers p. Input is terminated by the end-of-file seperator.
Output
For each p, print a single number that gives the number of primitive roots in a single line.
Sample Input
233179
Sample Output
10824
#include<iostream>#include<cstring>using namespace std;int euler(int n){ int i,ans=n; for(i=2; i*i<=n; i++) if(n%i==0) { ans=ans-ans/i; while(n%i==0) n/=i;//把该素因子全部约掉 //while(n%i==0); } if(n>1) ans=ans-ans/n; return ans;}int main(){ int n; while(cin>>n) { cout<<euler(n-1)<<endl; } return 0;}
0 0
- POJ 1284 Primitive Roots
- poj - 1284 - Primitive Roots
- Poj 1284 Primitive Roots
- 【POJ 1284】Primitive Roots
- POJ 1284 primitive roots
- POJ 1284Primitive Roots
- POJ 1284 Primitive Roots
- poj 1284 Primitive Roots
- POJ-1284-Primitive Roots
- POJ 1284 Primitive Roots(素数原根)
- poj 1284——Primitive Roots
- POJ 1284 Primitive Roots (求原根个数)
- poj 1284 Primitive Roots 【原根】【数论】
- POJ 1284 Primitive Roots 原根
- POJ-1284-Primitive Roots 解题报告
- poj 1284 Primitive Roots 求素数元根数
- POJ 1284 Primitive Roots (原根)
- POJ 1284 Primitive Roots(欧拉函数)
- win7 如何批量删除指定日期以前的文件
- HTML <a> 标签的小知识
- Xcode8出现AQDefaultDevice (173): skipping input stream 0 0 0x0
- 服务器热更新(动态加载DLL)
- 重载equal和hashCode
- POJ 1284 Primitive Roots
- PAT甲级1063
- java 中&和&&的区别
- hashCode()的作用
- SSH配置
- 关于调用三方地图实现路线查询的分享!
- 混合开发之webView加载html,android 和 html之间进行数据交互
- Android 实现 遮罩动画效果
- ffplay如何支持多协议