随笔分类 - 数学
摘要:#include<bits/stdc++.h> typedef long long ll ; #define mod 99999997 #define gcd __gcd #define rep(i , j , n) for(int i = j ; i <= n ; i++) #define red
阅读全文
摘要:##一、卡特兰数简介 卡特兰数是组合数学中的一种著名数列,通常用如下通项式表示: \(f(n) = \frac{C{n \atop 2n}}{n+1}\) 递推表示: \(f(n) = \sum^{n-1}_{i=0}{f(i)*f(n-i-1)}\) 组合表示: \(f(n) = C^n_{2n}
阅读全文
摘要:https://codeforces.com/contest/1305/problem/E 题意:要求构造n个数满足m个平衡,平衡规则:(i , j , k)1 <= i < j < k <= n && ai + aj = ak . 解法:构造1 ,2 , 3 ..... n 可知该序列有最大得平衡
阅读全文
摘要:https://codeforces.com/contest/1305/problem/C 题意:给出n个数ai , 模数m 。 计算 ∏1<=i<=j<=n|a[i] - a[j]|mod m 2 <= n <= 2e5 , 1 <= m <= 1000. 解法:直接暴力n方必超时。分析发现当n>
阅读全文
摘要:题意:在n*m的网格中,找至少一边平行x或y的面积为2的三角形个数。 解法:分情况考虑 1、两边平行x和y 1*2 或 2 * 1 矩形 有四个。 2、一边平行x或y 长度为1 或 2. //#include <bits/stdc++.h> #include <cstdio> #include <c
阅读全文
摘要:http://poj.org/problem?id=2661 题意:给定n, 2n > k! . 求最大的k 解法:两边取log比较。 //#include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <cmath> #
阅读全文
摘要:题意:Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak. n (n ≤ 30), k (k ≤ 109) and m (m < 104) 输出结果矩阵 解法: 若 n是偶数 S
阅读全文
摘要:http://oj.jxust.edu.cn/contest/Problem?id=1702&pid=6 题意:有n个人,现在有一个聚会,每个人都可以选择参加或者不参加。而参加的人中每个人要么只去送礼物,要么只接受礼物。不存在全部都接受礼物或者全部都送礼物的情况(这样要么没人送礼物,要么没人接受礼物
阅读全文
摘要:http://oj.jxust.edu.cn/contest/Problem?id=1702&pid=4 题意:给你一个数n,分成几个数之和使这些数乘积最大x。 求(1/n) %x. 解法:要使乘积最大尽可能多的分出3 , 三种情况, 1、n%3 == 0 ,全分成3的乘积。 2、n%3 == 1
阅读全文
摘要:http://oj.jxust.edu.cn/contest/Problem?id=1702&pid=1 题意:给你一个整数n(1 <= n <= 40000),问拆成3个素数之和有多少种拆法? 解法:暴力减枝。先筛选出来范围内所有素数,暴力循环第1、2个素数,第3个通过n-a-b特判递增和是否为素
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5976 题意:给你一个数n,拆成不同的几份,使乘积最大。 解法:从2开始拆 2 , 3 , 4 ....l , 最后会余下x , 0<=x <= l ; 再将x从后往前依次分配1给各元素。 1、x == l:3*4
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2048 题意:n个人抽签,每个人不选择自己的概率。 错排思想: 当n个编号元素放在n个编号位置,元素编号与位置编号各不对应的方法数用people(n)表示,那么people(n-1)就表示n-1个编号元素放在n-1
阅读全文

浙公网安备 33010602011771号