NOIP2012同余方程

2013年11月7日7,2822

题目描述

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

输入

输入文件为 mod.in。
输入只有一行,包含两个正整数 a, b,用一个空格隔开。

输出

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

样例输入

3 10

样例输出

7

提示

「数据范围」

对于 40%的数据,2 ≤b≤ 1,000;

对于 60%的数据,2 ≤b≤ 50,000,000;

对于 100%的数据,2 ≤a, b≤ 2,000,000,000。

代码

 

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
orzhzwerGeeking Recent comment authors
  Subscribe  
提醒
orzhzwer
orzhzwer

黄学长高考加油!

Geeking
Geeking

谢 已懂

问一下
Apache is functioning normally
是什么意思
我的blog 显示的