
数论
zzuli-dk
这个作者很懒,什么都没留下…
展开
-
AtCoder Beginner Contest 151 E - Max-Min Sums
题目链接题意:给你n个数和一个K (表示要重n个数中找出K个数)在K个数中求出 最大值减去最小值的差的总和。并对10^9+7取余涉及知识点:逆元,组合数思路:对于每一位数,考虑其作为最小值和最大值出现的可能。所以在这里需要排序,在一个有序数列中,最小值和最大值一定是出现在首尾两端。所以只要每次固定首尾判断以其开头或结尾的组合数即可。注意:最后的输出可能为负数#i...原创 2020-01-16 10:54:58 · 395 阅读 · 0 评论 -
xor序列 线性基
题目链接线性基: 若干数的线性基是一组数a1,a2,...ana1,a2,...an,其中axax的最高位的11在第xx位。 通过线性基中元素xor出的数的值域与原来的数xor出数的值域相同。#include <iostream>#include <cstdio>using namespace std;const int MAXN = 10000...原创 2018-09-09 12:26:37 · 245 阅读 · 0 评论 -
向量的数量积,向量积,混合积及应用
http://wenku.baidu.com/link?url=vKzZSSrCdYbfej5dfWZOFOzahSoQoO8SoC1RC7XCHVvDWZEhw7lFj76qzAx2hWDTMDfccbp4pBbZfOCNt57o-kVB1xD6z3vWVh9GCO-g01K (百度文库详解) 简单的总结一下: 一:数量积(点积,点乘,内积) a · b =|a|*|b|* c...原创 2016-10-29 09:46:24 · 7108 阅读 · 0 评论 -
hdu 6185 Covering 求递推式的板子
#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <vector>#include <string>#include <map>#include <set>#include <cassert>using namespace std;#define rep(i,a,n) f原创 2017-08-31 12:57:13 · 411 阅读 · 0 评论 -
逆元的三种解法
1.费马小定理2.扩展欧几里得3.通用法ab\frac {a}{b}mod m = a mod (b*mod) /b原创 2017-09-16 13:16:56 · 529 阅读 · 0 评论 -
ACM数论 板子
#include<bits/stdc++.h>using namespace std;const int MAXN= 100005;const int mod = 1e9+7;typedef long long LL;LL c[1005][1005];LL mu[MAXN];LL euler[MAXN];int mu[MAXN];void Mubius()//莫比乌斯...原创 2017-07-31 13:56:34 · 1061 阅读 · 0 评论 -
欧里几德的应用
acm.zzuli.edu.cn 1905小火山的跳子游戏Description 小火山和火山火山在一块玩跳子游戏。规则如下: 1:跳子的起始位置为0,棋盘大小从1到N 2:每次跳子跳k步。 例如当前位置为i, 那么下一步为i + k 3:跳子过程中,碰到1或N则往回跳。例如当前位置为4, N = 6, K = 5的时候, 那么下次跳子, 应该是 5, 6原创 2016-08-11 15:00:26 · 809 阅读 · 0 评论 -
hdu 1796 容斥定理
How many integers can you find Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integers in the set. For转载 2017-07-27 09:12:54 · 299 阅读 · 0 评论 -
hdu 6069 区间筛
题意:求出i满足l到r区间所有 i^k次方的因子的数量的和。 思路:对10^6的区间进行素数筛, 求出其质因数,再根据每个质因数的(1+number*k)的乘积求出因子和。#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>using namespace std;const int MAXN = 1e原创 2017-08-03 18:43:41 · 216 阅读 · 0 评论 -
扩展欧几里德模板及讲解
形如ax+by=m,求二元一次不等式的一组特解。m = gcd(a, b);推导:ax+by = gcd(a, b); —– 1 bx + (a%b)y = gcd(b, a%b); —–2由于a%b = a - a/b*b; bx + (a - a / b * b)y = gcd(b, a%b) ; ——3 从一式得二式的推导过程为 根据等效定理: 1式 <=>3式 bx =b原创 2016-10-06 14:42:08 · 570 阅读 · 0 评论 -
牛顿迭代法求平方根
可以用来求解方程的近似解.比较常见的就是求解平方根。比如求解x^2=a原理:设一个点(猜想点)坐标为(x, x^2-a),求出该点在曲线上的切线与x轴的交点,求导可以得到直线斜率,然后可以写出直线方程,一直迭代下去可以得到近似解。比如求x^2=2 猜想解为4。#include <cstdio>#include <iostream>#include <cstring>#include <alg原创 2017-05-06 10:17:56 · 588 阅读 · 0 评论 -
51nod 中国剩余定理
看了好久,才发现原来自己曾经用过的方法,这只是一种推广。就是单因子勾件法。每次找到能被其中一个除数除剩一,能被其他整除的数。最后加起来,然后对总和求余。#include#include #include #include using namespacestd;typedef longlong LL;const int N =15;原创 2016-11-18 10:59:57 · 405 阅读 · 0 评论 -
51nod N的阶乘的长度 V2(斯特林近似)斯特林近似公式
输入N求N的阶乘的10进制表示的长度。例如6! = 720,长度为3。Input第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 1000)第2 - T + 1行:每行1个数N。(1 Output共T行,输出对应的阶乘的长度。Input示例3456Output示例233斯特灵公式是一条用来取n原创 2016-11-21 22:11:39 · 763 阅读 · 0 评论 -
POJ 1061 青蛙的约会 扩展欧几里德- 猪都懂啦 = =
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %lld & %llu SubmitStatus Description 两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问原创 2016-10-06 15:09:15 · 379 阅读 · 0 评论 -
poj 1006 中国剩余定理
根据单因子构件凑成法(能对于变化的余数都能快速求解)思想:求出23, 28, 33三个互素(前提)的分别余数为一的情况, 就介绍式一的情况,其他两式同理可得。式一:{ x =23 * n1 + 1; x = 28 * n2 ; x = 33 * n3;}x满足被28和33整除,除以23余1,这就意味着在28和33的公倍数下找被23除余1的数,经过计算原创 2016-10-16 18:08:13 · 656 阅读 · 0 评论 -
light oj 1134
DescriptionYou are given an array with N integers, and another integer M. You have to find the number of consecutive subsequences which are divisible by M.For example, let N = 4, the array conta原创 2016-09-10 20:14:08 · 316 阅读 · 0 评论 -
POJ 1061 青蛙的约会
青蛙的约会Time Limit: 1000MS Memory Limit: 10000KB 64bit IO Format: %lld & %lluSubmit StatusDescription两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直原创 2016-09-10 20:19:08 · 375 阅读 · 0 评论 -
hdu 3037 Saving Beans lucas定理
DescriptionAlthough winter is far away, squirrels have to work day and night to save beans. They need plenty of food to get through those long cold days. After some time the squirrel family thinks tha原创 2016-09-27 09:51:46 · 287 阅读 · 0 评论 -
HDU 1576 (A/B)扩展欧几里德定理
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uHDU 1576Description要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。Input原创 2016-09-11 11:22:28 · 372 阅读 · 0 评论