#include  <iostream>
using namespace std;
#define ll long long
const int N = ;
ll n,p,r;
ll poww(ll a,ll b){
ll ans =1ll;
while(b){
if(b&) ans =ans*a%p;
b>>=;
a=a*a%p;
}
return ans%p;
}
int main()
{
//每次都要注意-1 -1的情况
scanf("%lld%lld%lld",&n,&p,&r);
if(n>=*p){
if(r==){
printf("%lld 1\n",p+);
}
else{
printf("-1 -1\n");
}
}
else if(n>=p){
if(r==){
int flag =;
for(ll i=;i<=n;i++){
if(i!=p)//起初if的{}写错了
{
printf("%lld 1\n",i);
flag =;
break;
}
}
if(!flag)printf("-1 -1\n"); //n=p=2
}
else{
ll ans=1ll;
for(ll i=;i<=n;i++) {
if(i!=p) ans =ans*i%p;
}
int flag =;
for(ll i=;i<p;i++){
if(ans*i%p==r) {
printf("%lld %lld\n",p,i);
flag =;
break;
}
}
if(flag==) printf("-1 -1\n");
}
}
else{
ll ans =1ll;
for(ll i=;i<=n;i++) ans =ans*i%p;
int flag =;
ans = poww(ans,p-);//放到里面会超时
for(ll i=;i<=n;i++){
ll x= r*i%p*ans%p;
// ans/i*x%p==r
// x=r*i%p/ans%p;
if(x>=&&x<i){
printf("%lld %lld\n",i,x);
flag =;
break;
}
}
if(!flag) printf("-1 -1\n");
}
return ; }

最新文章

  1. php安装的一点点事 ---wampserver
  2. 标识符,unicode和GBK
  3. Npoi实现Excel绘制功能
  4. 详解CSS中clear属性both、left、right值的含义
  5. Mysql denied for user &#39;odbc@localhost&#39; || denied for user &#39;root@localhost&#39;
  6. 支持Ajax跨域访问ASP.NET Web Api 2(Cors)的简单示例教程演示
  7. select()函数以及FD_ZERO、FD_SET、FD_CLR、FD_ISSET(转)
  8. xml装php数组
  9. SPI Flash
  10. CentOS的ssh sftp配置及权限设置(流程相当完整)(关闭了SElinux才能上传了)
  11. SQlServer---时间的操作
  12. file_get_contents和curl对于post方式的解决办法
  13. ActiveMQ笔记——技术点汇总
  14. php中各种定义变量的方法
  15. Excel 2010高级应用-条状图(五)
  16. SVN系列操作(二)&amp;svn不显示图标的解决方法
  17. css3 实现波浪(wave)效果
  18. 机器学习实战1-1 KNN电影分类遇到的问题
  19. 简单的图像显著性区域特征提取方法-----opencv实现LC,AC,FT
  20. select as table

热门文章

  1. 谷歌浏览器web worker出现cannot be accessed from origin &#39;null&#39;错误
  2. 《ArcGIS Runtime SDK for Android开发笔记》——(2)、Android Studio基本配置与使用
  3. SQLServer 连接和联合
  4. 复制windows CMD命令行中的内容
  5. Docker build 安装报错, Could not open requirments file: [Errno 2] No such file or directory:&#39;requirements.txt&#39;
  6. Arduino-定义串口
  7. Jmeter入门7 测试中使用到的几个定时器和逻辑控制器
  8. Illegal access:this web application instance has been stopped already
  9. node.js 练习2 (调用函数)
  10. 编写第一个OpenACC程序