- 博客(198)
- 收藏
- 关注
原创 ACdream区域赛指导赛之专题赛系列(1)の数学专场
Contest : ACdream区域赛指导赛之专题赛系列(1)の数学专场A:EOF女神的相反数题意:n(思路:water/** this code is made by shiyuan* Problem: 1095* Verdict: Accepted* Submission Date: 2014-05-24 19:06:37* Time: 0 MS* Mem
2014-05-25 00:36:38
1968
原创 Linear Programming
Linear Programming, Simplex Algorithmwiki: Simplex_algorithmwenku: 《浅谈信息学竞赛中的线性规划》Template: CodeExercise:uva10498.cpp
2014-03-27 20:39:34
1109
原创 Inclusion–exclusion principle
Wiki:Inclusion–exclusion principleStatement:Example:一个正整数序列a[1],a[2],a[3]...,a[n],一定存在一个x,y使得a[x]+a[x+1]+..+a[y]是n的倍数。proof:构造前n'项和S[n'],则出现两种情况:1)S[k']是n的倍数 2)S[k']对n的余数必然属于{1,2,.
2014-03-27 00:51:40
3787
原创 Integer Partition
Problem 1 Suppose p(n,k) means the number of partition of an integer into parts the largest of which is k (this problem are always equivalent to the number of the partition of an integer into no mor
2014-03-27 00:51:10
1733
原创 CF 232 div1
A.On Number of Decompositions into Multipliers题意:m=a1*a2...*an,求m拆分成n个数的排列思路:对m质因数分解之后,对每个质因子的幂用隔板法分成n份,C(x+n-1,n-1)Code:a.cppB.On Sum of Fractions题意:v(n)表示不超过n的最大素数,u(n)表示超过n的最小素数,求si
2014-02-27 19:11:39
1479
原创 Generating Function
Wiki:Generating_function Easy:TankyWoo matrix67Essay:《母函数的性质及应用》 Practice: Easy: Normal: Poj1322 Chocolate 题意:C(思路:无解的情况当然是m>n或m>c或(n-m)&1.对于C种巧克力出现的次数要么为奇数,要么为偶数.g
2014-02-24 23:30:29
1362
原创 Stable Marriage Problem
Problem:给出n个男人心中n个女人的排名,和n个女人心中n个男人的排名,求一种匹配使之形成稳定匹配。(稳定指的是形成的集合中,任意两对之间,不存在某个人和某个人在一起 比集合中的分配更优)详见维基百科:Stable_marriage_problemmatrix67的分析非常有趣:matrix67 Solution:function stableMatching {
2014-02-23 19:00:34
1325
原创 CF 231 div2
A.呵呵Code:a.cppB.Very Beautiful Number题意:一个数a(p)a(p-1)a...a2a1 * x = a1a(p)a(p-1)...a3a2思路:小学奥数,枚举个位,依次推出十位,百位,至于为什么是最小解,我当时写的时候还真没考虑Code:b.cppC.Dominoes题意:给出初始4种牌的个数,求一种摆放方法,使得每列
2014-02-21 22:33:37
1334
原创 CF 230 div2
A.呵呵B.没看C.Blocked Points题意:给出半径R,求圆内最外圈的整点的个数思路:平分成四份,对于每部分,可以找一个对称轴,特判0和接近对称轴的那个值Code:c.cpp D.Tower of Hanoi题意:给出3根柱子的汉诺塔间移动圆盘的消耗,求从第一根柱子移动n个盘子到第三根的最小花费思路:因为大盘不能放在小盘的上面,
2014-02-19 15:47:54
1362
原创 Contest of whu 2013.4
题目:woj 1471~14802013-4-23 whu 校赛Unsolved:A D ISolution:whu2013A.All Your Bases题意:求树上删边的最小费用思路:图论,不会Code:nullB.Beautiful Cities题意:n个城市修地铁,每个城市的出度不大于1,求方案数思路:
2014-02-13 14:08:58
1085
1
原创 数学模版
一.数论部分1.素数测试#include #include #include #include #include #include using namespace std; #define Times 10 typedef long long LL; mapmp; LL random(LL n) { return
2014-02-12 21:22:45
1107
原创 Code in 2013
hdu1042.cpp water 高精度hdu1316.cpp water 高精度hdu1005.cpp waterhdu1719.cpp water mathhdu1098.cpp waterhdu1071.cpp waterhdu1299.cpp waterhdu3117.cpp water mathhdu3792.cpp wa
2014-02-12 20:41:17
1578
1
原创 Contest of cug 2013.6
题目: Contest - 2013校赛暨华中邀请赛2013-6-2 cug 校赛Unsolved: B F H KSolution: cug2013A.Segment题意:求一维坐标中n(思路:排序,起点相同的保留长度最长的然后按x从小到大往右扫,mx记录当前出现的最右端点l表示当前线段的左边,r表示右边,r=min(v[i].y,mx);Co
2014-02-08 16:06:07
959
原创 Contest of hust 2013.12
题目:problems2013-12-8 hust 校赛Unsolved: D J A.Beautiful sky题意:模拟,旋转和对称都算一种思路:记录对某点的相对位置Code:hust1624.cppB.Chessboard题意:求四连通块中的最大值思路:并查集Code:hust1625.cppC.Cutting rope
2014-01-19 14:31:23
1120
原创 Training 2013.12
1.Codechef Strange Matrix http://www.codechef.com/problems/RRMATRIX题意:求纵向分布,横向分布重合数字个数思路:设重合的坐标为i,j,那么(i-1)*m+j=(j-1)*n+i(i-1)*m+(j-1)=(j-1)*n+(i-1)(i-1)*(m-1)=(j-1)*(n-1)i=(j-1)*(n-1)
2013-12-23 10:25:10
1153
原创 hdu 3369 Robot
题目:hdu 3369 Robot题意:告诉你从周几开始,到第n天总的学会单词的个数,其中第i天学会i^k个单词,周末学会单词为0思路:给的k的范围比较小,n的范围比较大开始想的是,枚举k,但是这样对于n并没有影响所以,我们要处理的应该是,i^k+(i+7)^k+(i+14)^k+....(i+7*j)^k这样的一个通式由于k的范围比较小,展开成k+1项二项式表示之后可以构造矩
2013-12-13 15:18:59
1451
原创 线段树(单点更新)
1. hdu 1166 敌兵布阵单点更新,区间求和,最裸的线段树#include #include #include using namespace std;#define maxn 50010#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1struct Tree{ int l,r,num;}tree[maxn<<2]
2013-11-29 01:25:13
1115
原创 Codeforces 208 div2 D. Dima and Hares
题目:Codeforces 208 div2 D. Dima and Hares tag :dp思路:dp[i][0] 表示i先于i+1 前 i 项的最大值 dp[i][1] 表示i后于i+1 前 i 项的最大值注意:求最大值的时候要注意最后一项,如果单纯求max(dp[n][1],dp[n][0])就错了,因为dp[n][1]没有第n+1项
2013-11-19 22:20:08
1379
原创 Codeforces 200 div1 C. Read Time
题目:Codeforces 200 div1 C. Read Time tag :二分思路:开始思路二分没错,就是忽略了一种情况。贪心想的话是,对于当前能访问到的地方尽量先访问,从左往右。但是有可能会忽略的是,先往右边扫,然后再往左,也有可能是先往左扫,再往右扫。细节注意点,不然会Wa的很惨。#include #include #include #include
2013-11-13 16:21:34
1113
原创 Codeforces 211 div2 D. Renting Bikes
题目:Codeforces 211 div2 D. Renting Bikes tag :二分思路:二分求出最大租车数mid,对于排序后的b,p,对应相减为:p[mid+1-i]-b[n+1-i]#include #include #include #include #include using namespace std;#define maxn 100010
2013-11-12 20:22:18
1041
原创 Codeforces 209 div2 D. Pair of Numbers
题目:D. Pair of Numbers思路:预处理每个数最右边和最左边能够整除它的下标,然后暴力,记得去重,不然会Wa tag :dp + 预处理#include #include #include #include #include #include #include using namespace std;#define maxn 30001
2013-11-05 08:53:50
1152
原创 Codeforces 209 div2 C. Prime Number
题目:C. Prime Number思路:通分之后,分母是x^sum,分子是sigma(x^(sum-a[i])),首先能提取的公因式是min(x^(sum-a[i])),对于剩下的,看产生的1能不能形成ax的形式,while搞定 tag :暴力#include #include #include #include #include using namespace
2013-11-05 08:50:10
1152
原创 CodeChef November Challenge 2013 » Yet Another Cute Girl
题目:Yet Another Cute Girl Chef doesn't love math anymore. He loves Sasha. Sashen'ka is cute.Chef goes on a date with her. Flowers are boring, while numbers are not. He knows that most of all
2013-11-04 21:04:55
1312
原创 CF I. Matrix
题目:CF I. Matrixtag:预处理+暴力#include #include #include #include #include #include using namespace std;#define maxn 410int a[maxn][maxn];int b[maxn][maxn];int c[maxn][maxn
2013-10-24 19:45:26
835
原创 CF L. Rolling Cube
题目:CF L. Rolling Cubetag:模拟#include #include #include #include #include #include using namespace std;#define maxn 100010int b[7];struct Cube{ int a[7]; void right()
2013-10-24 19:41:15
871
原创 CF A. Arrangement of RGB Balls
题目:CF A. Arrangement of RGB Balls 思路:找规律这题样例中已经把答案都给出来了,最大最小值之差大于等于2的肯定无解,0 1 1 和 0 0 1 需要特判,然后 a a a 是6种,a b b 和 a a b 都是2种#include #include #include #include using namespace
2013-10-23 09:27:03
869
原创 CF K. Killer Challenge
题目:CF K. Killer Challenge思路:状态dp前8项素因子的积就超过了100w,所以状态至多只有2^8个#include #include #include #include #include #include using namespace std;#define maxn 1000010bool vis[maxn];vecto
2013-10-23 09:20:31
664
原创 hdu 3221 Brute-force Algorithm
题目:hdu 3221 Brute-force Algorithm题意:很简单,枚举几项就知道了状态不好,sb了,错了好多遍#include #include #include #include #include using namespace std;typedef __int64 LL;LL mod,p,fib[60];struct Matrix{
2013-10-18 19:20:08
775
原创 《猫·谜》
// 《团队激励与方法》 要求写的推理小说 // 我跟华仔一人写了一半。。。写了一天。。拼出来的。。。= = 两个人也是团队么 // 难道这是传说中的团队合作一早上七点十分,Ethan像往常一样离开公寓。天气很好,很容易让人产生一丝丝清晨的愉悦,可是Ethan并没有停下脚步,留恋泥土清新的味道,而是自顾自地向车站走去。等公交的时候,他点上一根烟。他瞥了一眼垃圾桶,没有他
2013-10-17 17:39:15
1619
原创 hdu 4301 Divide Chocolate
题目:hdu 4301 Divide Chocolate题意:2*n的巧克力分成k份的方案数思路:跟铺砖的是一样的用dp[i][j][k]表示前i-1列已经处理好了,i列切成j块,k=0表示第i列两块属于同一部分,k=1表示第i列两块不属于同一部分。这里列出第i+1列和第i列的状态,用数字区别不同#include #include #includ
2013-10-11 12:44:37
1102
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人