
同余定理+逆元
yuebaba
鶸鶸鶸
展开
-
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 Input2...原创 2018-07-29 08:41:25 · 362 阅读 · 0 评论 -
乘法逆元(扩展欧几里德算法)
给出2个数M和N(M < N),且M与N互质,找出一个数K满足0 < K < N且K * M % N = 1,如果有多个满足条件的,输出最小的。Input输入2个数M, N中间用空格分隔(1 <= M < N <= 10^9)Output输出一个数K,满足0 < K < N且K * M % N = 1,如果有多个满足条件的,输出最小的...原创 2018-07-29 08:50:24 · 259 阅读 · 0 评论 -
3的幂的和 (大数取余)
求:3^0 + 3^1 +...+ 3^(N) mod 1000000007Input输入一个数N(0 <= N <= 10^9)Output输出:计算结果Sample Input3Sample Output40#include<cstdio>typedef long long ll;int mod = 1000000007;...原创 2018-07-29 08:52:40 · 435 阅读 · 0 评论 -
Integer Divisibility(大数取余)
If an integer is not divisible by 2 or 5, some multiple of that number in decimal notation is a sequence of only a digit. Now you are given the number and the only allowable digit, you should report t...原创 2018-07-29 08:54:01 · 640 阅读 · 0 评论 -
Large Division (还是大数取余)
Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b * c....原创 2018-07-29 08:55:19 · 159 阅读 · 0 评论