嘟嘟嘟

这道题就是求一个奇素数\(p\)的原根数量。   

公式是\(\varphi(\varphi(p))\)。又因为\(p\)是质数,所以就是\(\varphi(p - 1)\)。

(证明啥的我不会……)

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define enter puts("")
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
#define rg register
typedef long long ll;
typedef double db;
const int INF = 0x3f3f3f3f;
const db eps = 1e-8;
//const int maxn = ;
inline ll read()
{
ll ans = 0;
char ch = getchar(), last = ' ';
while(!isdigit(ch)) last = ch, ch = getchar();
while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
if(last == '-') ans = -ans;
return ans;
}
inline void write(ll x)
{
if(x < 0) x = -x, putchar('-');
if(x >= 10) write(x / 10);
putchar(x % 10 + '0');
} int n;
int phi(int n)
{
int ans = n;
for(int i = 2; i * i <= n; ++i)
if(n % i == 0)
{
ans = ans / i * (i - 1);
while(n % i == 0) n /= i;
}
if(n > 1) ans = ans / n * (n - 1);
return ans;
} int main()
{
while(scanf("%d", &n) != EOF) write(phi(n - 1)), enter;
return 0;
}

CF284A Cows and Primitive Roots的更多相关文章

  1. 【HDU 4992】 Primitive Roots (原根)

    Primitive Roots   Description We say that integer x, 0 < x < n, is a primitive root modulo n i ...

  2. POJ 1284 Primitive Roots 原根

    题目来源:POJ 1284 Primitive Roots 题意:求奇素数的原根数 思路:一个数n是奇素数才有原根 原根数是n-1的欧拉函数 #include <cstdio> const ...

  3. POJ 1284:Primitive Roots(素数原根的个数)

    Primitive Roots Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5709 Accepted: 3261 Descr ...

  4. POJ 1284 Primitive Roots 数论原根。

    Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2479   Accepted: 1385 D ...

  5. poj 1284 Primitive Roots (原根)

    Primitive Roots http://poj.org/problem?id=1284 Time Limit: 1000MS   Memory Limit: 10000K       Descr ...

  6. poj1284 Primitive Roots

    Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4775   Accepted: 2827 D ...

  7. POJ1284 Primitive Roots [欧拉函数,原根]

    题目传送门 Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5434   Accepted:  ...

  8. poj 1284 Primitive Roots(未完)

    Primitive Roots Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3155   Accepted: 1817 D ...

  9. POJ_1284 Primitive Roots 【原根性质+欧拉函数运用】

    一.题目 We say that integer x, 0 < x < p, is a primitive root modulo odd prime p if and only if t ...

随机推荐

  1. linux中find与rm实现查找并删除文件

    find命令: find . -name '*.log' #查找当前目录下的log文件 查找并删除: find . -name '*.log' -type f -print -exec rm -rf ...

  2. IIS利用X-Forwarded-For获得来访者的真实IP

    https://help.aliyun.com/knowledge_detail/37948.html

  3. 微信小程序(一)--简单的介绍

    转自:https://developers.weixin.qq.com/miniprogram/dev/index.html 响应的数据绑定 框架的核心是一个响应的数据绑定系统. 整个小程序框架系统分 ...

  4. 【SSH网上商城项目实战10】商品类基本模块的搭建

    转自:https://blog.csdn.net/eson_15/article/details/51354932 前面我们完成了与商品类别相关的业务逻辑,接下来我们开始做具体商品部分. 1. 数据库 ...

  5. [LeetCode]Swap Nodes in Pairs题解

    Swap Nodes in Pairs: Given a linked list, swap every two adjacent nodes and return its head. For exa ...

  6. Java CountDownLatch解析(下)

    写在前面的话 在上一篇CountDownLatch解析中,我们了解了CountDownLatch的简介.CountDownLatch实用场景.CountDownLatch实现原理中的await()方法 ...

  7. CSS,js,html

    图片盗链问题使用以下meta标签解决 <meta name="referrer" content="never"> Chrome 中文界面下默认会将 ...

  8. csharp:FlowLayoutPanel

    /// <summary> /// 集合添加的控件 /// 涂聚文20150339 /// </summary> public void AddNewTextBox() { P ...

  9. Bzoj3277:串

    题面 传送门 Sol 广义\(sam\) 每个\(sam\)的状态开\(set\)记录属于哪些串 \(parent\)树上启发式合并\(set\) 然后每个串就在上面走,通过不停地跳\(parent\ ...

  10. drupal7 获取当前使用的主题的名称

    直接引用全局变量就行: 参考: 代码测试: global $theme, $theme_key; echo $theme; echo '<br>'; echo $theme_key; 结果 ...