要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。

Input

数据的第一行是一个T,表示有T组数据。

每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)。

Output

对应每组数据输出(A/B)%9973。

Sample Input

2

1000 53

87 123456789

Sample Output

7922

6060

瞎jb用了一下逆元就直接ac了,对于逆元还是有点不知不解的

  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4. #include<cmath>
  5. #include<string.h>
  6. #include<algorithm>
  7. #define sf scanf
  8. #define pf printf
  9. #define cl clear()
  10. #define pb push_back
  11. #define mm(a,b) memset((a),(b),sizeof(a))
  12. #include<vector>
  13. typedef __int64 ll;
  14. typedef long double ld;
  15. const ll mod=9973;
  16. using namespace std;
  17. const double pi=acos(-1.0);
  18. ll a,b;
  19. ll niyuan(ll a)
  20. {
  21. ll r=1,b=9971,ans=a;
  22. while(b)
  23. {
  24. if(b&1) r=ans*r%mod;
  25. ans=ans*ans%mod;
  26. b>>=1;
  27. }
  28. return r;
  29. }
  30. ll solve(ll a,ll b)
  31. {
  32. return a*niyuan(b)%mod;
  33. }
  34. int main()
  35. {
  36. int re;
  37. cin>>re;
  38. while(re--)
  39. {
  40. cin>>a>>b;
  41. cout<<solve(a,b)<<endl;
  42. }
  43. }

随机推荐

  1. aglio报错解决

    Cannot write or read cache for themes (ENOENT on cache folder) aglio -i ./api.md -o api.html >> ...

  2. webapi帮助文档swagger

    nuget安装Swashbuckle包 修改SwaggerConfig文件 //c.IncludeXmlComments(GetXmlCommentsPath()); //设置接口描述xml路径地址 ...

  3. PL/SQL学习笔记之条件控制语句

    一:IF-THEN语句 IF (condition) THEN commands; END IF; 二:IF-THEN_ELSE语句 IF (condition) THEN S1; ELSE S2; ...

  4. array2json() - Convert PHP arrays to JSON

    array2json is a PHP function that will convert the array given as its argument into a JSON string. T ...

  5. 研究傅里叶变换的一本好书<<快速傅里叶变换及其C程序>>

    快速傅里叶变换及其C程序 <快速傅里叶变换及其C程序>是中国科学技术大学出版社出版的.本书系统地介绍了傅里叶变换的理论和技术,内容包括傅里叶变换(FT)的定义.存在条件及其性质,离散傅里叶 ...

  6. C#访问MySQL数据库的方法

    C#访问MySQL数据库的方法 (1)首先需要下载C#访问MySQL数据库的ADO.NET驱动程序 下载地址为: http://dev.mysql.com/downloads/connector/ne ...

  7. 在代码中设置RelativeLayout布局中标签的android:layout_toLeftOf、android:layout_toRightOf等属性

    需要动态改变RelativeLayout里面控件的相对位置,经一个技术群的群友提示,找到了如下的方法,做下记录:   RelativeLayout.Layoutparams params = (Rel ...

  8. Atitit 项目文档规范化与必备文档与推荐文档列表

    Atitit 项目文档规范化与必备文档与推荐文档列表 ===========比较重要的必备文档========== 项目组名单通讯录( 包括项目组,客户沟通人等 需求文档 原型ui文档 开发计划表 项 ...

  9. pandas DataFrame(3)-轴

    和numpy数组(5)-二维数组的轴一样,pandas DataFrame也有轴的概念,决定了方法是对行应用还是对列应用: 以下面这个数据为例说明: 这个数据是5个车站10天内的客流数据: rider ...

  10. linux每日命令(17):which命令

    我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索: which 查看可执行文件的位置. whereis 查看文件的位置. locate 配合数据库查看文件位置. f ...