![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
ACM__数论
数论题目
P1n9
这个作者很懒,什么都没留下…
展开
-
初学康托展开和逆康托展开
转载地址:https://blog.csdn.net/wbin233/article/details/72998375这篇博客讲的相当清楚了,转载一下1、简述康托展开是一个全排列到一个自然数的双射,常用于构建hash表时的空间压缩。设有n个数(1,2,3,4,…,n),可以有组成不同(n!种)的排列组合,康托展开表示的就是是当前排列组合在n个不同元素的全排列中的名次。2、原理X=a[n]...转载 2018-09-27 08:57:08 · 181 阅读 · 0 评论 -
SDUT3899
“浪潮杯”山东省第八届ACM大学生程序设计竞赛G题 快速幂或取模运算#include<iostream>#include<cstdio>#include<cstring>#include<cmath>using namespace std;#define MAXN 1000000007long long add(int n,int m){ long long ans;原创 2017-07-08 16:12:16 · 366 阅读 · 0 评论 -
hdu5950(递推的矩阵快速幂)
unsigned int 0~4294967295 int -2147483648~2147483647 unsigned long 0~4294967295 long -2147483648~2147483647 long long的最大值:9223372036854775807 long long的最小值:-9223372036854775808 unsigned原创 2017-09-15 09:17:14 · 197 阅读 · 0 评论 -
无法拯救我的菜------焦作网络赛 L. Poor God Water
地址:https://nanti.jisuanke.com/t/31721矩阵快速幂 这道题是根据递推关系构造矩阵 取每2个观察递推关系 1,aa 2,ab 3,ac 4,ba 5,bb 6,bc 7,ca 8,cb 9,cc 添加第三位,1 –> 2,3。 2 –>4,5。 3 –> 7,8,9。 4 –> 1,3。5 –> 4,6。6–>...原创 2018-09-15 22:29:21 · 240 阅读 · 0 评论 -
无法拯救我的菜-----徐州网络赛 A. Hard to prepare
地址:https://nanti.jisuanke.com/t/31453题意:题意:n个数字排成一圈,每个数字范围[0, 2^k-1],问有多少种不同的序列满足对于所有相邻的两个数字,它们同或值不能为0,其中第一个数字和最后一个数字也算相邻。(0#include<bits/stdc++.h>using namespace std;typedef long long LL...原创 2018-09-10 15:20:21 · 198 阅读 · 0 评论 -
Technocup 2019 - Elimination Round 1 D. Vasya and Triangle
地址:http://codeforces.com/contest/1030/problem/D思路:因为三个点是整数点, S=(1/2)*(x1y2+x2y3+x3y1-x1y3-x2y1-x3y2) = (n * m) / k;如果2 * n * m / k是分数的话,那就不存在三个整数点,又因为k >= 2;所以必存在三个点,可以这样构造以原点作直角三角形,三点都在坐标轴上,找两个这...原创 2018-09-24 10:47:06 · 299 阅读 · 0 评论 -
Codeforces Round #511 (Div. 2) C. Enlarge GCD
地址:http://codeforces.com/contest/1047/problem/C先将数组中的所有数的gcd求出来,每个数除掉gcd值,对剩余的数进行map计数,可以减少分解质因子的次数,然后统计每个质因子是数组中里多少个数的质因子,找出最大值,答案就是n - 这个数,如果数组里的数都变成1,则输出-1;998ms,卡过去的,其实一个个分解质因子太慢了,应该是变筛边处理#incl...原创 2018-09-22 23:50:20 · 213 阅读 · 0 评论 -
一个数的因子个数求解公式
转载:http://www.cnblogs.com/565261641-fzh/p/8641852.html对于一个自然数N,都可以分解质因子得到如下形式:转载 2018-11-06 19:26:32 · 1399 阅读 · 0 评论 -
输入文章标题
找规律#include<bits/stdc++.h>using namespace std;typedef long long LL;const int inf = 0x3f3f3f3f;#define mp make_pair#define pb push_back#define fi first#define se secondint main(){ ...原创 2018-11-23 20:03:00 · 194 阅读 · 0 评论 -
Codeforces Round #538 (Div. 2) C. Trailing Loves (or L'oeufs?)
地址:http://codeforces.com/contest/1114/problem/C刚开始想错了,每次一有思路就着急敲代码,每次敲完之后输样例发现走不通了,应该对应每个样例之后都解释的通,心中敲定做法之后,然后再敲;思路:对b分解质因数之后,记录其质因数及其个数a;然后再求其1~n中对应质因数的个数b(利用筛素数的原理,先找出公因子为一个b的个数(n / b),再求公因子为两个b...原创 2019-02-11 10:44:38 · 222 阅读 · 0 评论 -
Find The Determinant III 行列式求解
Given a NxN matrix A, find the Determinant of A % P.InputMultiple test cases (the size of input file is about 3MB, all numbers in each matrix are generated randomly).The first line of every test ca...原创 2019-03-08 21:47:43 · 267 阅读 · 0 评论 -
容斥原理模板
hdu4336容斥原理模板:dfs部分//hdu4336#include&lt;bits/stdc++.h&gt;using namespace std;#define out(x) cout&lt;&lt;#x&lt;&lt;": "&lt;&lt;x&lt;&lt;endlconst doubl转载 2018-09-08 19:27:58 · 306 阅读 · 0 评论 -
Codeforces Round #505 B Weakened Common Divisor
地址:http://codeforces.com/contest/1025/problem/B做的时候还把a,b进行分解质因素,不需要,a*b后的值两个数的质因子均包括了,直接求gcd即可。。。。 先判断最后是否存在一个WCD数,利用(a[i] * b[i])之间求gcd,当最后得数为1时,说明不存在;否则,因为可能存在g还是a[i] * b[i]的情况,所以再和每个单独的a[i]或b[i]...原创 2018-08-30 13:18:43 · 118 阅读 · 0 评论 -
poj2499(逆向找根,用迭代相除法来优化)
POJ-2499 Binary Tree Time Limit: 1000 ms / Memory Limit: 65536 kb Description Background Binary trees are a common data structure in computer science. In this problem we will look at an infinite ...原创 2018-04-23 16:41:49 · 283 阅读 · 0 评论 -
hdu3240(卡特兰数+分解素数+逆元)
Counting Binary Trees Time Limit: 3000 ms / Memory Limit: 32768 kb Description There are 5 distinct binary trees of 3 nodes:Let T(n) be the number of distinct non-empty binary trees of no more ...原创 2018-04-19 23:27:49 · 233 阅读 · 0 评论 -
HDU-1495 非常可乐(bfs 或数论)
HDU-1495 非常可乐 Time Limit: 1000 ms / Memory Limit: 32768 kb Description 大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和...原创 2018-05-13 18:53:51 · 428 阅读 · 0 评论 -
指数循环节问题
指数循环节问题:需要对指数进行降幂处理才能计算比如:ans = 2 ^ n % mod 其中1 <= n <= 10^100000和1 <= m <= 10^6这里由于n很大,所以需要进行降幂。那么实际上有如下降幂公式A^B mod C = A ^ (B % phi(C) + phi(C)) mod C;有了上述公式,很多题目就可以迎刃而解了。...原创 2018-07-28 21:06:26 · 187 阅读 · 0 评论 -
牛客多校第六场 --- C Generation I
链接:https://www.nowcoder.com/acm/contest/144/C 来源:牛客网Generation I 时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 Oak is given N empty and non-repeatable sets wh...原创 2018-08-04 21:51:20 · 349 阅读 · 1 评论 -
牛客多校第四场A ternary string ----推公式和指数循环节
链接:https://www.nowcoder.com/acm/contest/142/A 来源:牛客网Ternary String 时间限制:C/C++ 4秒,其他语言8秒 空间限制:C/C++ 131072K,其他语言262144K 64bit IO Format: %lld 题目描述 A ternary string is a sequence of digits, whe...原创 2018-07-31 16:10:52 · 237 阅读 · 0 评论 -
ACM常用数学公式
转载: ACM常用数学公式汇总: https://blog.csdn.net/qq_26891045/article/details/51490709 ACM常用几何基本数学公式: https://blog.csdn.net/ACMore_Xiong/article/details/51899284 acm用到的数学公式记录 https://blog.csdn.net/qq_37383...转载 2018-08-06 20:36:37 · 353 阅读 · 0 评论 -
无法拯救我的菜系列------hdu6395 Sequence
Sequence Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1725 Accepted Submission(s): 651Problem Description Let us define a sequence...转载 2018-08-14 22:38:15 · 145 阅读 · 0 评论 -
组合数公式
需要了解的公式:转载 2018-08-03 15:27:09 · 2419 阅读 · 0 评论 -
无法拯救我的菜----南京网络赛 j sum
地址:https://nanti.jisuanke.com/t/30999果然是菜。。。。n = p1^a1*p2^a2*p3^a3………..,如果a1,a2,a3….有一个数大于2,则f(n) = 0;假设有m个ai = 1,则f(n) = 2 ^ m;如果有0个,f(n) = 1; 不能一个一个的分解质因数求解,得先打表预处理,用素数筛来打f表 当p 为素数时,f(p) = 2; 当...原创 2018-09-01 20:49:30 · 205 阅读 · 0 评论 -
数论小总结
欧几里得GCD(求最大公约数):int gcd(int n,int m){ return (m) ? gcd(m,n%m) : n;}最小公倍数LCM:int LCM(int n,int m){ return n / gcd(n,m) * m;}扩展欧几里德exgcd: 求ax+by=c直线方程的问题。 作用:1、求不定方程。 2、求解模线性方程(原创 2017-08-13 23:03:19 · 597 阅读 · 0 评论