Description

  求关于 x 同余方程 ax ≡ 1 (mod b)的最小正整数解。

Input Description

  输入只有一行,包含两个正整数 a, b,用 一个 空格隔开。

Output Description

  输出只有一行包含一个正整数x0,即最小正整数解,输入数据保证一定有解。


  裸的exgcd,不多讲了。。

  

 #include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm> typedef long long ll; using namespace std; ll x,y; void exgcd(ll a,ll b)
{
if(b==)
{
x=;
y=;
return;
}
exgcd(b,a%b);
ll
sb=x;
x=y;
y=sb-(a/b*y);
} void solve(ll a,ll b)
{
exgcd(a,b);
printf("%lld",(x+b)%b);//最小正整数解
} int main()
{
ll a,b;
scanf("%lld%lld",&a,&b);
solve(a,b);
return ;
}

最新文章

  1. 在DirectShow中支持DXVA 2.0(Supporting DXVA 2.0 in DirectShow)
  2. Vue.js之v-for
  3. Nodejs express 文件上传
  4. 完美C++(第5版)(双色)
  5. C# sql语句拼接时 like情况的防sql注入的用法
  6. C语言面试题(二)
  7. SDAutoLayout:比masonry更简单易用的自动布局库
  8. 复制中的NOT FOR REPLICATION
  9. 360每日自动签到,领取积分 (java httpclient4.x)
  10. Introducing RecyclerView(一)
  11. hdu2429Ping pong
  12. [刷题]算法竞赛入门经典(第2版) 5-15/UVa12333 - Revenge of Fibonacci
  13. java基础---字符串string
  14. Vuex 源码学习(一)
  15. Switch-case 内定义变量的问题
  16. 关于python中的operator.itemgetter()函数的用法
  17. CSS简单使用
  18. NopCommerce用.net core重写ef
  19. Python实现文字聊天室
  20. 01c语言基础

热门文章

  1. Service通信详解
  2. sql常识-SQL 通配符
  3. Visual Studio Gallery
  4. Delegate&amp;Event
  5. OC6-网址分割
  6. 【leetcode】8. String to Integer (atoi)
  7. Libcurl笔记二
  8. Qt学习总结-ui篇(二)
  9. python mysqldb使用dictcursor
  10. mysql 运行sql脚本文件