题目链接 :http://acm.hdu.edu.cn/showproblem.php?pid=1576
题目类型 :数论
题目知识点:数学推理 公式运用
题目描述:一个公式(A/B)%9973 因为A 很大 所以只给出 A %9973
再给你一个数字 B
让你求这个式子的值;
推导公式
设 A=B*N;
根据同余定理 : A %9973 = (B % 9973 )*(N%9973)%9973
N%9973为所求 又因为 N %9973 属于【0,9972】 所以枚举N%9973的值,满足条件则输出
代码如下:
1 #include <stdio.h> 2 int main() 3 { 4 int t ; 5 __int64 n,b; 6 scanf("%d",&t); 7 while (t--) 8 { int i; 9 scanf("%I64d %I64d",&n,&b); 10 for (i = 0; i<= 9973 ; i++) 11 if((b%9973*i%9973)%9973 == n) 12 printf("%d\n",i); 13 14 } 15 return 0; 16 }