
数论
文章平均质量分 76
CCloth
这个作者很懒,什么都没留下…
展开
-
[容斥][数论]Count GCD Codeforces1750D
根据题意可以得到gcd(gcd(b[1], b[2], ..., b[i-1]), b[i]) = a[i],也就是gcd(a[i-1], b[i]) = a[i],那么a[i-1]%a[i]必须为0,否则无解。给出一个长度为n的数组a,要求构造出一个长度也为n的数组b,满足a[i] = b中前i个数的最大公约数且b[i]小于等于m,问不同的方案数。原创 2022-11-10 23:49:22 · 333 阅读 · 0 评论 -
[扩展欧几里得]Draw a triangle 2022年CCPC桂林站E
给出两点坐标,需要输出第三个点坐标,使这三个点构成一个面积最小的三角形,要求点坐标必须为整数。原创 2022-11-05 19:14:26 · 649 阅读 · 0 评论 -
[思维]Factorial Divisibility Codeforces1754D
之后开一个500000的桶数组cnt,cnt[i]用来记录i这个阶乘出现的次数,之后对于i从1到x-1,将cnt[i]转为小于等于i的数,也就是如果i!每出现了i+1次就将其凑成一个(i+1)!最后剩下个数一定小于等于i,这么处理完之后a[1]!(m小于等于i),而某些位置m*i!一定为0,也就是只要i从1到x-1中出现了一个非零的cnt[i],那么最后一定模x!给出n和x,接下来给出长度为n的数组a,问a[1]!原创 2022-10-23 18:33:10 · 353 阅读 · 0 评论 -
[思维][组合数学]Madoka and The Corruption Scheme Codeforces1717D
首先可以对于任何一个你的方案,都可以转换成左边选手一定获胜的方案,只需要左右子树交换一下位置即可,这样接下来表述会比较清楚。有2^n个参赛选手,每两人之间进行比赛,胜者之间再次比赛,这样n轮后会出现一个最终胜者,现在你可以任意安排第一轮的比赛顺序,并且对于每次比赛你都可以选择哪方获胜,最终目标是让最后获胜者的编号尽量小,不过另一个人有至多k次干扰你的机会,每次干扰可以指定一场比赛,使其结果与你预期相反,问最终即使受到干扰下获胜者的最小编号。原创 2022-09-05 15:42:43 · 331 阅读 · 0 评论 -
[矩阵快速幂][等比矩阵求和]Gauss Fibonacci HDU1588
首先先利用矩阵化简一下表达式,设矩阵a为[1,1;1,0],也就是求Fibonacci第n项用到的那个矩阵,根据之前的知识,我们可以将f(i)转换为a^(i-1)*[f(1);f(0)],设矩阵[f(1);要注意给出的参数从0~1e9,对于边界情况一定要仔细斟酌!给出b,k,n,mod,设f(i)表示Fibonacci第i项,求f(b)+f(b+k)+......+f(b+(n-1)*k)的值余mod后的结果。...原创 2022-07-16 21:52:12 · 240 阅读 · 0 评论 -
[质因数分解]樱花 洛谷P1445
题目背景又到了一年樱花盛开的时节。Vani 和妹子一起去看樱花的时候,找到了一棵大大的樱花树,上面开满了粉红色的樱花。Vani 粗略估计了一下,一共有足足n!片花瓣。Vani 轻柔地对她说:“你知道吗?这里面的一片花瓣代表着你,我从里面随机摘一片,能和你相遇的概率只有 1/n!那么小。我该是多么的幸运,才让你今天这么近地站在我面前。相信我,我一定会把这亿万分之一的缘分变为永远。”粉红的樱花漫天飞舞,妹子瞬间被 Vani 感动了。她轻轻地牵起了他的手,和他相依而坐。这时,她突然看到田野的尽头...原创 2022-04-02 09:41:04 · 137 阅读 · 0 评论 -
[找规律][二分]杨辉三角 2021年蓝桥杯
题目描述下面的图形是著名的杨辉三角形:如果我们按从上到下、从左到右的顺序把所有数排成一列,可以得到如下数列:1, 1, 1, 1, 2, 1, 1, 3, 3, 1, 1, 4, 6, 4, 1, ...给定一个正整数 N,请你输出数列中第一次出现 N 是在第几个数?输入输入一个整数 N。输出输出一个整数代表答案。样例输入6样例输出13提示【评测用例规模与约定】对于 20% 的评测用例,1 ≤ N ≤ 10;对于所有评测用例,1 ≤ N原创 2022-02-28 21:38:11 · 2198 阅读 · 1 评论 -
[lcm][推导][枚举]Benefit UVA11889
RecentlyYaghoubis playing a new trick to sell some more. When somebody gives himATomans, he who never has appropriate changes, asks forBTomanssuch that lowest common multiple ofAandBequals toCand he will pay back a round bill. Or otherwise tak...原创 2022-02-22 11:11:09 · 192 阅读 · 0 评论 -
[思维]Bank Robbery LightOJ1163
On one very cold morning, Poltu decides to rob a bank. But while trying to hack into the security system, he found that it is locked by some random value. He also found a pattern on the random number, that is if he chops off the last digit of a numberA, h.原创 2022-02-21 14:21:31 · 95 阅读 · 0 评论 -
[尾随0个数]Trailing Zeroes (II) LightOJ1090
Find the number of trailing zeroes for the following function:C(n, r)*p^qwhere n, r, p, q are given as Input.InputInput starts with an integer T (≤ 10000), denoting the number of test cases.Each case contains four integers: n, r, p, q (1 ≤ n, r,原创 2022-02-20 23:10:24 · 145 阅读 · 0 评论 -
[欧拉函数]Visible Lattice Points POJ3090
A lattice point (x,y) in the first quadrant (xandyare integers greater than or equal to 0), other than the origin, is visible from the origin if the line from (0, 0) to (x,y) does not pass through any other lattice point. For example, the point (4, 2)...原创 2022-02-17 21:09:43 · 448 阅读 · 0 评论 -
[欧拉函数][gcd]Longge‘s problem POJ2480
Longge is good at mathematics and he likes to think about hard mathematical problems which will be solved by some graceful algorithms. Now a problem comes: Given an integer N(1 < N < 2^31),you are to calculate ∑gcd(i, N) 1<=i <=N."Oh, I know,原创 2022-02-17 15:40:18 · 286 阅读 · 0 评论 -
[欧拉函数][gcd]Same GCDs CF1295D
You are given two integersaaandmm. Calculate the number of integersxsuch that 0≤x<mand gcd(a,m)=gcd(a+x,m).Note: gcd(a,b)is the greatest common divisor ofaand b.InputThe first line contains the single integerT(1≤T≤50) — the number of te...原创 2022-02-17 11:15:33 · 157 阅读 · 0 评论 -
[思维][gcd]Enlarge GCD CF1047C
Mr. F hasnnpositive integers, a1,a2,…,an.He thinks the greatest common divisor of these integers is too small. So he wants to enlarge it by removing some of the integers.But this problem is too simple for him, so he does not want to do it by himse..原创 2022-02-17 09:49:15 · 473 阅读 · 0 评论 -
[质因数分解][除法取余]Sumdiv LibreOJ10211
题目描述原题来自:Romania OI 2002求 A^B 的所有约数之和 mod 9901。输入格式输入两个整数 A,B。输出格式输出答案 mod9901。样例Input Output 2 3 15 2^3=8,8 的所有约数为 1,2,4,8,15 mod 9901=15,因此输出 15。数据范围与提示对于全部数据,0≤A,B≤5×10^7。题意: 输出A^B全部因数的和除9901的余数。分析: 这个原创 2022-02-16 20:25:56 · 665 阅读 · 0 评论 -
[gcd]Row GCD CF1459C
You are given two positive integer sequences a1,…,an and b1,…,bm. For each j=1,…,m find the greatest common divisor of a1+bj,…,an+bj.InputThe first line contains two integers n and m (1≤n,m≤2⋅105).The second line contains nn integers a1,…,an原创 2022-02-16 16:52:05 · 426 阅读 · 0 评论