- 博客(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 1886
原创 Linear Programming
Linear Programming, Simplex Algorithm wiki: Simplex_algorithm wenku: 《浅谈信息学竞赛中的线性规划》 Template: Code Exercise: uva10498.cpp
2014-03-27 20:39:34 1076
原创 Inclusion–exclusion principle
Wiki:Inclusion–exclusion principle Statement: 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 3624
原创 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 1674
原创 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.cpp B.On Sum of Fractions 题意:v(n)表示不超过n的最大素数,u(n)表示超过n的最小素数,求si
2014-02-27 19:11:39 1383
原创 Generating Function
Wiki:Generating_function Easy:TankyWoo matrix67 Essay:《母函数的性质及应用》 Practice: Easy: Normal: Poj1322 Chocolate 题意:C( 思路:无解的情况当然是m>n或m>c或(n-m)&1. 对于C种巧克力出现的次数要么为奇数,要么为偶数. g
2014-02-24 23:30:29 1282
原创 Stable Marriage Problem
Problem:给出n个男人心中n个女人的排名,和n个女人心中n个男人的排名,求一种匹配使之形成稳定匹配。(稳定指的是形成的集合中,任意两对之间,不存在某个人和某个人在一起 比集合中的分配更优) 详见维基百科:Stable_marriage_problem matrix67的分析非常有趣:matrix67 Solution: function stableMatching {
2014-02-23 19:00:34 1266
原创 CF 231 div2
A.呵呵 Code:a.cpp B.Very Beautiful Number 题意:一个数a(p)a(p-1)a...a2a1 * x = a1a(p)a(p-1)...a3a2 思路:小学奥数,枚举个位,依次推出十位,百位,至于为什么是最小解,我当时写的时候还真没考虑 Code:b.cpp C.Dominoes 题意:给出初始4种牌的个数,求一种摆放方法,使得每列
2014-02-21 22:33:37 1281 2
原创 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 1302 1
原创 Contest of whu 2013.4
题目:woj 1471~1480 2013-4-23 whu 校赛 Unsolved:A D I Solution:whu2013 A.All Your Bases 题意:求树上删边的最小费用 思路:图论,不会 Code:null B.Beautiful Cities 题意:n个城市修地铁,每个城市的出度不大于1,求方案数 思路:
2014-02-13 14:08:58 1047 2
原创 数学模版
一.数论部分 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 1071
原创 Code in 2013
hdu1042.cpp water 高精度 hdu1316.cpp water 高精度 hdu1005.cpp water hdu1719.cpp water math hdu1098.cpp water hdu1071.cpp water hdu1299.cpp water hdu3117.cpp water math hdu3792.cpp wa
2014-02-12 20:41:17 1546 4
原创 Contest of cug 2013.6
题目: Contest - 2013校赛暨华中邀请赛 2013-6-2 cug 校赛 Unsolved: B F H K Solution: cug2013 A.Segment 题意:求一维坐标中n( 思路:排序,起点相同的保留长度最长的 然后按x从小到大往右扫,mx记录当前出现的最右端点 l表示当前线段的左边,r表示右边,r=min(v[i].y,mx); Co
2014-02-08 16:06:07 934 1
原创 Contest of hust 2013.12
题目:problems 2013-12-8 hust 校赛 Unsolved: D J A.Beautiful sky 题意:模拟,旋转和对称都算一种 思路:记录对某点的相对位置 Code:hust1624.cpp B.Chessboard 题意:求四连通块中的最大值 思路:并查集 Code:hust1625.cpp C.Cutting rope
2014-01-19 14:31:23 1090 2
原创 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 1108
原创 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 1394
原创 线段树(单点更新)
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|1 struct Tree{ int l,r,num; }tree[maxn<<2]
2013-11-29 01:25:13 1052
原创 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 1344 1
原创 Codeforces 200 div1 C. Read Time
题目:Codeforces 200 div1 C. Read Time tag :二分 思路:开始思路二分没错,就是忽略了一种情况。 贪心想的话是,对于当前能访问到的地方尽量先访问,从左往右。但是有可能会忽略的是,先往右边扫,然后再往左,也有可能是先往左扫,再往右扫。 细节注意点,不然会Wa的很惨。 #include #include #include #include
2013-11-13 16:21:34 1086
原创 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 1012
原创 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 1126
原创 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 1124
原创 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 1278
原创 CF I. Matrix
题目:CF I. Matrix tag:预处理+暴力 #include #include #include #include #include #include using namespace std; #define maxn 410 int a[maxn][maxn]; int b[maxn][maxn]; int c[maxn][maxn
2013-10-24 19:45:26 808
原创 CF L. Rolling Cube
题目:CF L. Rolling Cube tag:模拟 #include #include #include #include #include #include using namespace std; #define maxn 100010 int b[7]; struct Cube { int a[7]; void right()
2013-10-24 19:41:15 832
原创 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 791
原创 CF K. Killer Challenge
题目:CF K. Killer Challenge 思路:状态dp 前8项素因子的积就超过了100w,所以状态至多只有2^8个 #include #include #include #include #include #include using namespace std; #define maxn 1000010 bool vis[maxn]; vecto
2013-10-23 09:20:31 636
原创 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 748
原创 《猫·谜》
// 《团队激励与方法》 要求写的推理小说 // 我跟华仔一人写了一半。。。写了一天。。拼出来的。。。= = 两个人也是团队么 // 难道这是传说中的团队合作 一 早上七点十分,Ethan像往常一样离开公寓。天气很好,很容易让人产生一丝丝清晨的愉悦,可是Ethan并没有停下脚步,留恋泥土清新的味道,而是自顾自地向车站走去。等公交的时候,他点上一根烟。他瞥了一眼垃圾桶,没有他
2013-10-17 17:39:15 1577 1
原创 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 1077
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人