![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数论
破晓aa
这个作者很懒,什么都没留下…
展开
-
How many integers can you find HDU - 1796 (容斥原理)
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 example, N=12, and M-integer...原创 2018-12-01 10:32:48 · 256 阅读 · 0 评论 -
GCD HDU - 1695 (容斥原理 + 欧拉函数)
Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y) = k. GCD(x, y) means the greatest common divisor of x and y. Since the number of choices may be very large, you're...原创 2018-12-03 16:38:42 · 210 阅读 · 0 评论 -
矩阵快速幂( C - Recursive sequence HDU - 5950)
题干就不说了,直接上分析。此题的递推公式为 f [ n ] = f [ n - 1 ] + 2 * f [ n - 2 ] + n ^ 4,难点就在于构造转移矩阵,转移矩阵构造出来整个题目也就解决了,当然还要注意如果题目给的n小于3,直接输出就好了(在这个点栽了一发。。)构造转移矩阵的难点在于如何处理n的四次方这一部分。在此提供一个方法,凡是有n次幂的时候基本上都可以用。因为要保持...原创 2018-09-12 09:28:34 · 270 阅读 · 0 评论 -
求逆元的几种方法
1.费马小定理:x的逆元等于x的mod - 2次方(要保证x与mod互质)2.扩展欧几里得:#include <iostream> using namespace std; int exgcd(int a, int b, int &x, int &y) ///“&x”,对x的引用,在函数里面也可更改x值,而不仅仅是更改原先值的副本{...原创 2018-12-08 15:43:04 · 2728 阅读 · 0 评论 -
A New Function (LightOJ - 1098) || (UVA 10830) (带一点思维的数论)
We all know that any integer number n is divisible by 1 and n. That is why these two numbers are not the actual divisors of any numbers. The function SOD(n) (sum of divisors) is defined as the summati...原创 2018-12-07 19:53:10 · 354 阅读 · 0 评论 -
求组合数(完善中.......)
1.杨辉三角递推法void init_trangle(){ for(int i = 0; i < 500; i ++) { cc[i][0] = cc[i][i] = 1; for(int j = 1; j < i; j++) { cc[i][j] =(cc[i - 1][j - 1] + cc[i - 1][j]) % mod; } }}2....原创 2018-11-29 16:57:30 · 186 阅读 · 0 评论 -
欧拉筛(筛素数,附上一点解释)
#include <iostream>#include <cstdio>#include <cstring>using namespace std;typedef long long ll;const int maxn = 1e6 + 100;ll n;bool vis[maxn];ll prime[100000];int cnt;...原创 2018-11-28 21:04:26 · 196 阅读 · 0 评论 -
快速幂算法
const int mod = 1e9 + 7;int pow(int a, int b){ int ans=1; while(b>0) { if(b%2==1) ans=ans*a % mod; a=a*a; a %= mod; b=b/2; } r...原创 2018-03-17 21:40:11 · 218 阅读 · 0 评论 -
最大公约数(gcd)
递归法:int gcd(int n ,int m){ if(m == 0) return n; else return gcd(m, n % m);}原创 2018-05-05 17:18:18 · 390 阅读 · 0 评论 -
容斥定理
对容斥定理不算太理解,在此贴上一道例题体会一下(山东省第九届ACM省赛F题)Problem DescriptionGiven l1,r1,l2,r2,l3,r3,l4,r4l_1,r_1,l_2,r_2,l_3,r_3,l_4,r_4l1,r1,l2,r2,l3,r3,l4,r4, please count the number of four-tuples (x1,x2,...原创 2018-05-24 20:20:36 · 191 阅读 · 0 评论 -
欧拉函数
欧拉函数:对于正整数n,少于或等于n且与n互质的正整数(包括1)的个数。顺便贴上互质数的定义:互质数为数学中的一种概念,即两个或多个整数的公因数只有1的非零自然数。下面为欧拉函数的几个性质:(我们暂且把某一个整数的欧拉函数值记做Phi(n))1. Phi(1)= 1;2. 如果n为质数,Phi(n) = n - 1;3. n为质数p的k次方,即n = p^k; ...原创 2018-05-27 11:07:22 · 551 阅读 · 0 评论 -
数学知识(acm)
1.与集合子集斐波那契数列的第n+2项同时也代表了集合{1,2,...,n}中所有不包含相邻正整数的子集个数。证明:归纳法证明—— n=1时,相应子集个数为2,为f(3); n=2时,相应子集个数为3,为f(4); n>=3时,若集合{1,2,...,n-2}的相应子集为f(n),集合{1,2,...,n-1}的相应子集为f(n-1) 则对于集合{1,...转载 2018-08-06 17:10:18 · 315 阅读 · 0 评论 -
Finite or not?
You are given several queries. Each query consists of three integers p, q and b. You need to answer whether the result of p/q in notation with base bis a finite fraction.A fraction in notation wit...原创 2018-06-04 21:07:22 · 292 阅读 · 0 评论 -
数论小知识点(补充中)
1. 2^n的位数:len = (int)(n * log10(2)) + 12.原创 2019-01-03 21:38:39 · 184 阅读 · 0 评论