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: ...
随机推荐
- flash、js 函数 互相调用
js调用flex函数 flex 利用ExternalInterface.addCallback(“注册的方法名”,As中的函数名)进行注册 js中,用document.getElementById(“ ...
- Agc019_C Fountain Walk
传送门 题目大意 给定网格图上起点和终点每个格子是长为$100$米的正方形,你可以沿着线走. 平面上还有若干个关键点,以每个关键点为圆心,$10$为半径画圆,表示不能进入圆内的线,但是可以从圆周上走, ...
- mysql_union all 纵向合并建表_20170123
年前事情比较多,博客不能每天更新了. 1.union all 纵向建表和left join 横向建表的数据结构区别 先贴代码 后面再补充 (#销售确认额 SELECT '05收货销售额' AS 标识, ...
- 2017/2/22怎么判断mongodb服务已经启动了?
打开任务管理器,看看服务下面是否有个MongoDB,有就表示成功
- Jeesite开垦
1. userIndex里面,$ctx是在哪里定义的? 就是request.context 2. 增加新的包后,扫描配置修改1) spring-context.xml文件中,扫描非@controlle ...
- java基础知识(15)----StringBuffer与StringBuilder
StringBuffer字符串缓冲区: 构造一个其中不带字符的字符串缓冲区,初始容量为 16 个字符.特点:1:可以对字符串内容进行修改.2:是一个容器.3:是可变长度的.4:缓冲区中可以存储任意类型 ...
- Python类(四)-多态
多态即一个接口,多种实现 按照平常直接调用 # -*- coding:utf-8 -*- __author__ = "MuT6 Sch01aR" class Person(obje ...
- javascript——对象的概念——函数 3 (使用技巧)
1.回调函数:将函数A传给函数B,由函数B来执行A,则称A为回调函数. 例1: 例2 function addone(a){;}; //定义一个回调函数 function mulitiply(a,b, ...
- Oracle——判断对象是否存在(未完工)
一.系统表: 1.User_Tables:存储用户下的所有表的信息: 2.dba_tables:存储管理员权限下的所有表的信息: 3.all_tables:存储所有表的信息. 4.all_Tab_Co ...
- 问题:C#属性;结果:c# 属性
c# 属性 属性:get { //读属性代码 } set { //写属性代码 } public class Person{private string name;public string Name{ ...