EZOJ #73
分析
我们知道如果对于模数$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的更多相关文章
- 报错: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 ...
- 重新想象 Windows 8.1 Store Apps (73) - 新增控件: DatePicker, TimePicker
[源码下载] 重新想象 Windows 8.1 Store Apps (73) - 新增控件: DatePicker, TimePicker 作者:webabcd 介绍重新想象 Windows 8.1 ...
- 73条日常Linux shell命令汇总,总有一条你需要!
转载: 73条日常Linux shell命令汇总,总有一条你需要! 1.检查远程端口是否对bash开放: echo >/dev/tcp/8.8.8.8/53 && echo &q ...
- 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 ...
- 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)目前 ...
- OPatch failed with error code 73
前几天给一套LINUX下的RAC数据库打补丁升级,有一台机器更新失败了,相关的异常内容如下: Restoring "/u01/app/oracle/11.2.0/db_1" to ...
- 欧拉工程第73题:Counting fractions in a range
题目链接:https://projecteuler.net/problem=73 n/d的真分数 ,当d<=12000时 在 1/3 and 1/2 之间的有多少个 public class P ...
- (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 ...
- hdu5634 BestCoder Round #73 (div.1)
Rikka with Phi Accepts: 5 Submissions: 66 Time Limit: 16000/8000 MS (Java/Others) Memory Limit: ...
随机推荐
- hdoj-1013-Digital Roots(九余数定理)
题目链接 #include <iostream> using namespace std; int main() { string a; int b; ") { b = ; ;i ...
- Ubuntu 安装arm-linux-gcc编译器
/********************************************************************************** * Ubuntu 安装arm-l ...
- C++中预定义的宏
以下信息摘自与标准C++的文档中. 如果把这些宏加在程序的日志中,它将为开发人员进行问题分析提供了很好的帮助. standard c++ 1998版The following macro names ...
- 使用 MLCC 替代电解电容需要注意几点 (2018-07-23)
使用 MLCC 替代电解电容需要注意几点 容量,MLCC 在高压时容量会降到标称的 30~50% 以下 1. MLCC 的 ESR 很低,比较适合高频 DCDC 输出. MLCC 会有压电效应,可能会 ...
- Windbg内核调试之一: Vista Boot Config设置
Windbg进行内核调试,需要一些基本的技巧和设置,在这个系列文章中,我将使用Windbg过程中所遇到的一些问题和经验记录下来,算是对Kernel调试的一个总结,同时也是学习Windows系统内核的另 ...
- AD的差分输入与单端输入
AD的差分输入与单端输入 单端输入,输入信号均以共同的地线为基准.这种输入方法主要应用于输入信号电压较高(高于1V),信号源到模拟输入硬件的导线较短(低于15 ft,1ft=304.8mm),且所有的 ...
- (转)NHibernate之Generator主键生成方式
本文转载自:http://www.cnblogs.com/lemon-love/archive/2010/03/10/1683058.html (1) assigned主键由外部程序负责生成,无需NH ...
- 关于移动端的一些tip
移动端的一些tip 开发相关 关于viewport <meta name="viewport" content="name=value,name=value&quo ...
- Python:包、模块、类、函数的调用
一.关系 包一般指文件夹或者安装包(安装包一般也是压缩后的文件夹),里面包含多个.py文件(必须有一个__init__.py文件),一般也含有多个子包(或子文件夹): 一般一个.py文件就是一个模块, ...
- 【转】MEAN:Nodejs+express+angularjs+mongodb搭建前端项目框架NJBlog
http://www.cnblogs.com/mz121star/archive/2013/03/13/njblog.html 项目地址:https://github.com/mz121star/ ...