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: ...
随机推荐
- CCControlSwitch 、CCControlSlider、CCControlButton
/* *bool hasMoved(); 这里获取的不是开关是否正在被用户拨动,而是开关最终的状态是由用户手动拨动开关进行的, *还是用户点击开关进行的状态更改 */ CCControlSwitch* ...
- CodeForces - 150C :Smart Cheater (线段树,求最大连续区间)
I guess there's not much point in reminding you that Nvodsk winters aren't exactly hot. That increas ...
- freemarker实现第一个HelloWorld
第一步:引入freemarker jar包 第二步:创建templates下的test01.ftl 第三步:在web.xml下 第四步:编写后台代码 package com.wisezone.test ...
- 性能测试工具BenchmarkDotnet
.NET Core中的性能测试工具BenchmarkDotnet https://www.cnblogs.com/lwqlun/p/9671611.html 背景介绍 之前一篇博客中,我们讲解.NET ...
- LeetCode LFU Cache
原题链接在这里:https://leetcode.com/problems/lfu-cache/?tab=Description 题目: Design and implement a data str ...
- bzoj 3771 Triple——FFT
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3771 把方案作为系数.值作为指数,两项相乘就是系数相乘.指数相加,符合意义. 考虑去重.先自 ...
- 单端IO标准
单端标准 常用的单端IO标准是LVTTL和LVCMOS. 目前业界绝大部分FPGA/CPLD器件的LVCOMS的IO是由CMOS推挽(push-pull)驱动器构成的,这种结构是上面的PMOS管和下面 ...
- 侯捷STL学习(八)-- 深度探索deque
layout: post title: 侯捷STL学习(八) date: 2017-07-19 tag: 侯捷STL --- 第十八节 深度探索deque上 duque内存结构 分段连续,用户看起来是 ...
- windows黑科技-记录dns log
昨天看到袁哥微博,看到了这篇,今天测试了一下,记录下来: The DNS Client service does not log by default. However, if a file name ...
- mysql 回顾小练习
Student(id,sname,age,sex) 学生表 Course(id,cname,t_id) 课程表 SC(s_id,c_id,score) 成绩表 Teacher(id,Tname) 教师 ...