I - A/B
要求(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了,对于逆元还是有点不知不解的
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<string.h>
#include<algorithm>
#define sf scanf
#define pf printf
#define cl clear()
#define pb push_back
#define mm(a,b) memset((a),(b),sizeof(a))
#include<vector>
typedef __int64 ll;
typedef long double ld;
const ll mod=9973;
using namespace std;
const double pi=acos(-1.0);
ll a,b;
ll niyuan(ll a)
{
ll r=1,b=9971,ans=a;
while(b)
{
if(b&1) r=ans*r%mod;
ans=ans*ans%mod;
b>>=1;
}
return r;
}
ll solve(ll a,ll b)
{
return a*niyuan(b)%mod;
}
int main()
{
int re;
cin>>re;
while(re--)
{
cin>>a>>b;
cout<<solve(a,b)<<endl;
}
}
随机推荐
- aglio报错解决
Cannot write or read cache for themes (ENOENT on cache folder) aglio -i ./api.md -o api.html >> ...
- webapi帮助文档swagger
nuget安装Swashbuckle包 修改SwaggerConfig文件 //c.IncludeXmlComments(GetXmlCommentsPath()); //设置接口描述xml路径地址 ...
- PL/SQL学习笔记之条件控制语句
一:IF-THEN语句 IF (condition) THEN commands; END IF; 二:IF-THEN_ELSE语句 IF (condition) THEN S1; ELSE S2; ...
- 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 ...
- 研究傅里叶变换的一本好书<<快速傅里叶变换及其C程序>>
快速傅里叶变换及其C程序 <快速傅里叶变换及其C程序>是中国科学技术大学出版社出版的.本书系统地介绍了傅里叶变换的理论和技术,内容包括傅里叶变换(FT)的定义.存在条件及其性质,离散傅里叶 ...
- C#访问MySQL数据库的方法
C#访问MySQL数据库的方法 (1)首先需要下载C#访问MySQL数据库的ADO.NET驱动程序 下载地址为: http://dev.mysql.com/downloads/connector/ne ...
- 在代码中设置RelativeLayout布局中标签的android:layout_toLeftOf、android:layout_toRightOf等属性
需要动态改变RelativeLayout里面控件的相对位置,经一个技术群的群友提示,找到了如下的方法,做下记录: RelativeLayout.Layoutparams params = (Rel ...
- Atitit 项目文档规范化与必备文档与推荐文档列表
Atitit 项目文档规范化与必备文档与推荐文档列表 ===========比较重要的必备文档========== 项目组名单通讯录( 包括项目组,客户沟通人等 需求文档 原型ui文档 开发计划表 项 ...
- pandas DataFrame(3)-轴
和numpy数组(5)-二维数组的轴一样,pandas DataFrame也有轴的概念,决定了方法是对行应用还是对列应用: 以下面这个数据为例说明: 这个数据是5个车站10天内的客流数据: rider ...
- linux每日命令(17):which命令
我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索: which 查看可执行文件的位置. whereis 查看文件的位置. locate 配合数据库查看文件位置. f ...