传送门

分析

我们知道如果对于模数$P$有$gcd(x,P) = 1$则$x$一定有且仅有一个逆元,可以表示为

$x \equiv \frac{y}{1} (mod P)$

即为$xy \equiv 1(mod P)$

所以我们只需要找出与$P$互质的数的个数然后除以二再加上$i*i \equiv 1(mod P)$这种情况的个数即可

除以二的原因是相同的$x,y$会被统计两次

代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
int main(){
int n,m,i,j,k,ans,sum=,p;
scanf("%d",&p);
for(i=;i<p;i++)if(1ll*i*i%p==)sum++;
ans=p;
for(i=;i*i<=p;i++)
if(p%i==){
ans-=ans/i;
while(p%i==)p/=i;
}
if(p!=)ans-=ans/p;
cout<<(ans-sum)/+sum;
return ;
}

EZOJ #73的更多相关文章

  1. 报错:Unable to load configuration. - action - file:/E:/apache-tomcat-8.0.37/webapps/20161102-struts2-3/WEB-INF/classes/struts.xml:11:73

    第一种报错: 严重: Exception starting filter struts2Unable to load configuration. - action - file:/E:/apache ...

  2. 重新想象 Windows 8.1 Store Apps (73) - 新增控件: DatePicker, TimePicker

    [源码下载] 重新想象 Windows 8.1 Store Apps (73) - 新增控件: DatePicker, TimePicker 作者:webabcd 介绍重新想象 Windows 8.1 ...

  3. 73条日常Linux shell命令汇总,总有一条你需要!

    转载: 73条日常Linux shell命令汇总,总有一条你需要! 1.检查远程端口是否对bash开放: echo >/dev/tcp/8.8.8.8/53 && echo &q ...

  4. hadoop启动之后出现错误:Retrying connect to server: hadoop/192.168.73.100:9000. Already tried 0 time(s);

    INFO ipc.Client: Retrying connect to server: hadoop/192.168.73.100:9000. Already tried 0 time(s); re ...

  5. MySQL 5.1.73升级为MySQL 5.5.35详解

    一.前言 二.概述 三.安装MySQL 5.1.73 四.升级为MySQL 5.5.35 五.总结 注,测试环境 CentOS 6.4 x86_64,MySQL 版本(5.1.73.5.5.35)目前 ...

  6. OPatch failed with error code 73

    前几天给一套LINUX下的RAC数据库打补丁升级,有一台机器更新失败了,相关的异常内容如下: Restoring "/u01/app/oracle/11.2.0/db_1" to ...

  7. 欧拉工程第73题:Counting fractions in a range

    题目链接:https://projecteuler.net/problem=73 n/d的真分数 ,当d<=12000时 在 1/3 and 1/2 之间的有多少个 public class P ...

  8. (Problem 73)Counting fractions in a range

    Consider the fraction, n/d, where n and d are positive integers. If nd and HCF(n,d)=1, it is called ...

  9. hdu5634 BestCoder Round #73 (div.1)

    Rikka with Phi  Accepts: 5  Submissions: 66  Time Limit: 16000/8000 MS (Java/Others)  Memory Limit: ...

随机推荐

  1. @angular/cli项目构建--animations

    使用方法一(文件形式定义): animations.ts import { animate, AnimationEntryMetadata, state, style, transition, tri ...

  2. UVA - 11754 Code Feat (分块+中国剩余定理)

    对于一个正整数N,给出C组限制条件,每组限制条件为N%X[i]∈{Y1,Y2,Y3,...,Yk[i]},求满足条件的前S小的N. 这道题很容易想到用中国剩余定理,然后用求第k小集合的方法输出答案.但 ...

  3. [BZOJ5248][多省联测2018]双木棋chess

    bzoj luogu sol 首先,要保证一个格子的左边和上方都放满了棋子,就需要这个点的左上方那个矩形都放满了棋子. 这样放棋子状态就会是一个自左下至右上的轮廓线. 状态数?\(C_{20}^{10 ...

  4. python实现进程的并发

    __author__ = 'luozt' import telnetlib import multiprocessing import random def telnet(ip,hostname): ...

  5. CentOS7 yum安装mysql5.5/5.6并初始化

    https://blog.csdn.net/petrel2015/article/details/78822466 下载MySQL yum仓库文件 首先根据官网给出的建议,下载MySQL的仓库文件 h ...

  6. Northwind 示例数据库

    Northwind 示例数据库 Northwind Traders 示例数据库包含一个名为 Northwind Traders 的虚构公司的销售数据,该公司从事世界各地的特产食品进出口贸易. 下载地址 ...

  7. linux user date

    useradd username 添加用户 userdel username 删除用户 passwd username 设置用户密码 passwd 设置当前用户密码 passwd -d usernam ...

  8. asp.net过滤HTML标签,只保留换行与空格

    自己从网上找了一个过滤HTML标签的方法,我也不知道谁的才是原创的,反正很多都一样.我把那方法复制下来,代码如下: /// <summary> /// 去除HTML标记 /// </ ...

  9. UEditor富文本编辑器的使用 http://fex.baidu.com/ueditor/

    [转] http://fex.baidu.com/ueditor/ UEditor 介绍 UEditor 是由百度「FEX前端研发团队」开发的所见即所得富文本web编辑器,具有轻量,可定制,注重用户体 ...

  10. HDU1584(蜘蛛牌)

    蜘蛛牌 Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...