
数论
文章平均质量分 79
永夜莫明
菜是原罪
展开
-
A/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 Input2100...原创 2018-11-25 01:27:13 · 298 阅读 · 1 评论 -
51nod1040 最大公约数之和
题目链接http://www.51nod.com/Challenge/Problem.html#!#problemId=1040给出一个n,求1-n这n个数,同n的最大公约数的和。比如:n = 61,2,3,4,5,6 同6的最大公约数分别为1,2,3,2,1,6,加在一起 = 15输入1个数N(N <= 10^9)输出公约数之和输入样例6输出样例...原创 2019-06-25 14:03:56 · 233 阅读 · 0 评论 -
HeHe(积性函数)
题目链接https://cn.vjudge.net/contest/307680#problem/AIn the equation X^2≡X(mod N) where x∈[0,N-1], we define He[N] as the number of solutions.And furthermore, define HeHe[N]=He[1]*……*He[N]Now here ...原创 2019-06-25 15:34:02 · 630 阅读 · 0 评论 -
hdu5528Count a * b(数论)
题目链接https://cn.vjudge.net/problem/HDU-5528Marry likes to count the number of ways to choose two non-negative integersaandb less thanmto makea×b modm≠0.Let's denotef(m)as the number of ways...原创 2019-06-27 02:02:52 · 233 阅读 · 0 评论 -
Just Random(思维+数学找规律+容斥)
题目链接:https://cn.vjudge.net/problem/HDU-4790Coach Pang and Uncle Yang both love numbers. Every morning they play a game with number together. In each game the following will be done: 1. Coach Pang ...原创 2019-07-02 16:56:11 · 562 阅读 · 0 评论 -
51nod1192 gcd表中的质数(莫比乌斯反演入门题+分块)
题目链接http://www.51nod.com/Challenge/Problem.html#!#problemId=1192有一个M * N的表格,行与列分别是1 - M和1 - N,格子中间写着行与列的最大公约数Gcd(i, j)(1 <= i <= M, 1 <= j <= N)。例如:M = 5, n = 4。 1 2 3 4 51 1 1...原创 2019-06-27 19:09:29 · 314 阅读 · 0 评论 -
计数JS(容斥原理)
题目描述给定一个长度为n的序列a1..an,求m以内的不能被a1..an中任意一个ai整除的正整数有多少个?输入第一行两个数n,m接下来一行n个数,a1..an输出共一个数,即m以内的不能被a1..an中任意一个ai整除的正整数有多少个。样例输入3 20154 5 6样例输出1075提示对于 30% 的数据,1≤...原创 2019-07-09 15:16:31 · 297 阅读 · 1 评论 -
wyh的考核(dp/容斥原理)
链接:https://ac.nowcoder.com/acm/problem/15442来源:牛客网时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld题目描述wyh非常喜欢lol游戏,一天,他听说学校要选拔lol队员,他非常高兴的就去了,选拔规则是,一共有N个评委,每个评委根据线上对线...原创 2019-06-29 18:09:18 · 420 阅读 · 0 评论 -
最少拦截系统 (最长上升子序列)
某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统....原创 2019-07-16 19:18:59 · 221 阅读 · 0 评论 -
ABBA(组合数学/dp)
链接:https://ac.nowcoder.com/acm/contest/881/E来源:牛客网Bobo has a string of length 2(n + m) which consists of characters `A` and `B`. The string also has a fascinating property: it can be decomposed i...原创 2019-07-19 14:15:21 · 629 阅读 · 2 评论 -
幂塔问题/指数循环节模板
题目链接https://nanti.jisuanke.com/t/41299三爷的博客https://blog.youkuaiyun.com/lgz0921/article/details/100187260?tdsourcetag=s_pctim_aiomsg求a^(a^(a^(a……^a)))%m (共b个a)存个板子#include<bits/stdc++.h>#p...原创 2019-09-02 00:00:57 · 747 阅读 · 0 评论 -
幂一矩阵
题解https://blog.youkuaiyun.com/qq_26358509/article/details/71056436C++代码(60%)#include<cstdio>#include<iostream>#include<algorithm>#include<map>using namespace std;typedef ...原创 2019-05-23 20:16:17 · 302 阅读 · 0 评论 -
Dandelion(卡特兰数+费马小定理求逆元)
题目链接:http://whu2019.contest.codeforces.com/group/YyBKO8xFiH/contest/102167/problem/DD. Dandeliontime limit per test1.0 smemory limit per test256 MBinputstandard inputoutputstandard o...原创 2019-04-08 17:48:29 · 408 阅读 · 0 评论 -
求不定方程的正整数解和非负整数解各有几个(排列组合(高中数学)+费马小定理求逆元 )(Lucas定理?)
链接:https://ac.nowcoder.com/acm/contest/553/D来源:牛客网Chino的数学很差,因此Cocoa非常担心。今天,Cocoa要教Chino解不定方程。众所周知,不定方程的解有0个或者若干个。给出方程:Cocoa想知道这个不定方程的正整数解和非负整数解各有几个。题目对Chino来说太难啦,你能帮一帮Chino吗?输入描述:两个正...原创 2019-04-06 21:31:50 · 3792 阅读 · 0 评论 -
Diophantus of Alexandria(唯一分解定理)
Diophantus of AlexandriaDiophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first mathematicians to study equations where variables were restricted to integral...原创 2018-11-29 20:58:56 · 700 阅读 · 0 评论 -
Deciphering Password (唯一分解定理)
Deciphering PasswordXiaoming has just come up with a new way for encryption, by calculating the key from a publicly viewable number in the following way:Let the public key N = A^ B, where 1 &lt;= A,...原创 2018-11-29 21:45:29 · 345 阅读 · 0 评论 -
GCD(欧拉定理)
GCDThe greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For example,(1,2)=1,(12,18)=6.(a,b) can be easily found by t...原创 2018-11-30 16:56:40 · 1084 阅读 · 0 评论 -
GCD and LCM
Given two positive integers G and L, could you tell me how many solutions of (x, y, z) there are, satisfying that gcd(x, y, z) = G and lcm(x, y, z) = L?Note, gcd(x, y, z) means the greatest common...原创 2018-12-31 15:16:16 · 185 阅读 · 0 评论 -
L1-006 连续因子 (20 分)(搜索)
L1-006 连续因子 (20 分)一个正整数 N 的因子中可能存在若干连续的数字。例如 630 可以分解为 3×5×6×7,其中 5、6、7 就是 3 个连续的数字。给定任一正整数 N,要求编写程序求出最长连续因子的个数,并输出最小的连续因子序列。输入格式:输入在一行中给出一个正整数 N(1<N<231)。输出格式:首先在第 1 行输出最长连续因子的个数;然...原创 2019-03-04 20:34:21 · 570 阅读 · 0 评论 -
Couple doubi(打表找规律,数论)
Problem DescriptionDouBiXp has a girlfriend named DouBiNan.One day they felt very boring and decided to play some games. The rule of this game is as following. There are k balls on the desk. Every ba...原创 2019-03-17 11:32:07 · 435 阅读 · 0 评论 -
Romantic(拓展欧几里得)
The Sky is Sprite.The Birds is Fly in the Sky.The Wind is Wonderful.Blew Throw the TreesTrees are Shaking, Leaves are Falling.Lovers Walk passing, and so are You....................................原创 2019-03-29 18:51:32 · 174 阅读 · 0 评论 -
Modular Inverse(逆元)
题目连接:https://cn.vjudge.net/problem/ZOJ-3609The modular modular multiplicative inverse of an integer a modulo m is an integer x such that a-1≡x (mod m). This is equivalent to ax≡1 (mod m).InputTh...原创 2019-03-31 15:38:01 · 952 阅读 · 0 评论 -
Trailing Loves (or L'oeufs?)(唯一分解,尾零)
题目链接:http://codeforces.com/contest/1114/problem/C#include<cstdio>#include<map>#include<cstring>#include<algorithm>#include<cmath>#include<vector>using name...原创 2019-03-31 16:48:15 · 234 阅读 · 0 评论 -
蹲着还是站着(数论)
链接:https://ac.nowcoder.com/acm/contest/554/H来源:牛客网杨主席这段时间由于要找实习,所以非常焦躁。因为公司的面试都非常的难,杨主席不知道从哪入手。于是他就找了他的学长坑坑询问情况,坑坑告诉他要注重算法的学习,于是就给杨主席出了一个题目看看他算法学的怎么样,这道题是这样的:有N个人排成一排,从1到N按顺序依次编号,现在要执行N次操作,第一次操作让...原创 2019-04-05 15:16:54 · 236 阅读 · 0 评论 -
Quadratic equation(二次剩余模板题)
链接:https://ac.nowcoder.com/acm/contest/889/B来源:牛客网Amy asks Mr. B problem B. Please help Mr. B to solve the following problem.Let p = 1000000007.Given two integers b and c, please find two...原创 2019-09-04 23:56:13 · 430 阅读 · 0 评论