![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
同余定理+逆元练习
While.True
这个作者很懒,什么都没留下…
展开
-
B - 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-24 17:04:14 · 260 阅读 · 0 评论 -
C - 乘法逆元
给出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-24 17:05:48 · 1292 阅读 · 0 评论 -
D - 3的幂的和
求:3^0 + 3^1 +...+ 3^(N) mod 1000000007Input输入一个数N(0 <= N <= 10^9)Output输出:计算结果Sample Input3Sample Output40一项一项处理会超时,故可用等比数列公式转化成除法,再找逆元逆元,s = a1(1-q^n)/(1-q)//转化为等比数列前n...原创 2018-07-24 17:09:09 · 110 阅读 · 0 评论 -
E - 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-24 17:12:42 · 98 阅读 · 0 评论 -
F - 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-24 17:14:22 · 163 阅读 · 0 评论 -
A - 青蛙的约会
两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,...原创 2018-07-25 08:31:16 · 217 阅读 · 0 评论 -
n^n的末位数字 (快速幂模板)
给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字。Input一个数N(1 <= N <= 10^9)Output输出N^N的末位数字Sample Input13Sample Output3#include<stdio.h>#include<string.h>#include<algorithm&g...原创 2018-08-23 22:22:38 · 209 阅读 · 0 评论