- 博客(60)
- 收藏
- 关注
原创 最大子序列(牛客)
#include <cstdio>#include <algorithm>#include <cstring>#include <iostream>using namespace std;long long arr[1000006];///如果一个负数的绝对大于它前面的加和,那就将他们舍掉int main(){ long...
2019-09-24 12:51:24
230
原创 Conquer a New Region (并查集)hdu 4424
The wheel of the history rolling forward, our king conquered a new region in a distant continent. There are N towns (numbered from 1 to N) in this region connected by several roads. It's confirmed th...
2018-10-22 17:49:34
297
原创 重温 + 深入理解扩展欧几里德
欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数 gcd(a,b)由递推所得,自然需要初始值和递推式核心代码int gcd( int a, int b ){ while( b != 0 ) { int t = b; b = a%b; a = t; } return a;} ...
2018-08-09 20:47:30
220
原创 A^B的因子个数及因子和( 唯一分解定理 + 约数定理 + 等比数列求和 )
根据唯一分解定理 将一个数质因子分解A = p1^k1 * p2^k2 * p3^k3..............*pn^kn; 因为p1, p2,....pn均为素数, pn^kn因子个数为( k1 + 1)个 , A的所有因子个数为 ( k1+1)(k2+1)......*( kn+1)个 就是从每一个部分中选取一个数 A的因子和为( 1 + p1 + p1^...
2018-08-08 10:25:16
1259
原创 博弈( 异或)
Little Q and Little T are playing a game on a tree. There are nn vertices on the tree, labeled by 1,2,...,n1,2,...,n, connected by n−1n−1 bidirectional edges. The ii-th vertex has the value of wiwi. ...
2018-08-06 15:07:54
485
原创 b-number(dfs记忆化搜索 +数位 dp三维数组 )
A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. For example, 130 and 2613 are wqb-numbers, but 143 and 2639 ar...
2018-08-03 19:59:29
278
原创 线段树区间更新经典题目( D - Naive Operations HDU - 6315 )
In a galaxy far, far away, there are two integer sequence a and b of length n. b is a static permutation of 1 to n. Initially a is filled with zeroes. There are two kind of operations: 1. add l r: ...
2018-08-03 11:44:51
164
原创 数位 dp 入门 ( 不要62 )
看了好久的数位dp ,今天才算有点明白 ,但目前还处入门水平 理解有限这是个很好的入门题:杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。 不吉利的数字为所有含有4或62的号码。例如: 62315 73418 8...
2018-08-02 20:37:14
236
原创 Balanced Sequence ( 括号最大匹配个数)
Chiaki has nn strings s1,s2,…,sns1,s2,…,sn consisting of '(' and ')'. A string of this type is said to be balanced: + if it is the empty string + if AA and BB are balanced, ABAB is balanced, + if A...
2018-08-02 19:49:08
458
原创 线段树区间更新+题目
给你N个数,Q个操作,操作有两种,‘Q a b ’是询问a~b这段数的和,‘C a b c’是把a~b这段数都加上c。 需要用到线段树的,update:成段增减,query:区间求和 介绍Lazy思想:lazy思想,记录每一个线段树节点的变化值,当这部分线段的一致性被破坏我们就将这个变化值传递给子区间,大大增加了线段树的效率。 在此通俗的解释我理解的Lazy意思,比如现在需要对[a,b...
2018-08-01 15:28:44
251
原创 大数相除 (被除数范围较小)
手工计算除法的思路:凑整数,够除即除,不够除商0。在下手写代码之前,首先想清楚需要用什么存储数据,以及存储什么类型的数据。 存储所要除的大数:因为大数可能会超过int或者long long的范围,所以不能用其来进行存储,需要用string来存储。 除数:用int来进行存储即可。 计算得到的结果:将计算所得的每一位数据保存到整型数组中,int result[100001]。 每一次...
2018-07-27 19:00:52
324
原创 数论 ( 求取大数n^k的前3位与后3位)
求取大数的后k位比较简单 即利用快速幂 取c = 10^k就可以 模板:( 以 k = 3 为例)long long int quick_mod( long long int a, long long int b ){ long long int ans = 1; long long int c = 1000; a = a%c; while( b...
2018-07-27 09:52:00
1203
原创 欧拉函数( 数论) + 唯一分解定理
欧拉函数初步认识:在数论,对正整数n,欧拉函数是小于n的正整数中与n互质的数的数目(φ(1)=1)。此函数以其首名研究者欧拉命名(Euler's totient function),它又称为Euler's totient function、φ函数、欧拉商数等。 例如φ(8)=4,因为1,3,5,7均和8互质。 从欧拉函数引伸出来在环论方面的事实和拉格1.通式: 其中p1, p2...
2018-07-26 11:13:22
3052
原创 网络流( 最大流 )入门+板子
好不容易大概搞懂了网络流,写个博客巩固一下(盗了点图,请图主原谅) **定义 网络流与最大流**网络流是指给定一个有向图,和两个点–源点S和汇点T,点之间有连边, 每条边有一个容量限制,可以看作水管,网络流就是指由S点流到T点的一个可行流。 最大流就是指所有可行流里面最大的流。通俗的讲,就是由若干个运货点,一个是起点,一个是终点,有一些运货点由路相连,每条路有容量限制,走过那...
2018-07-25 20:14:31
2502
1
原创 质因子分解( 数论基础 )
#include<cstdio>#include<iostream>#include<cstring>#include<cstdlib>#include<algorithm>using namespace std;#define ma 65540int m[ma];int prim( ){ memset( m,...
2018-05-03 21:17:24
686
原创 超简单好理解 CodeForces - 645C
In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his k cows have decided to sta...
2018-04-23 19:50:05
395
原创 CodeForces - 484B 最大余数
You are given a sequence a consisting of n integers. Find the maximum possible value of (integer remainder of ai divided by aj), where 1 ≤ i, j ≤ n and ai ≥ aj.InputThe first line contains integer n ...
2018-04-22 20:49:48
569
1
原创 胡乱的一点知识点
ax == 1( modm )即axmod( m ) == 1///x为a在mod m下的逆元费马小定理 ///a^m-1 == 1( modm)a * a^m-2 == 1( mod m ) ///m必须为素数 且a m 互质函数lower_bound()在first和last中的前闭后开区间进行二分查找,返回大于或等于val的第一个元素位置。如果所有元素都小于val,则返回last的位置举例如...
2018-04-21 21:31:28
193
原创 买菜用了01 背包 wwwwwwwwwwwwww
电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。 某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。 Input多组数据。对于每组数据: 第一行为正整数n,表示菜的数...
2018-04-21 19:57:36
1799
原创 巧妙处理最长公共子序列
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14. InputThe fir...
2018-04-21 18:46:07
183
原创 一起数羊 hhhhhhhhB - Count the Sheep
Altough Skipping the class is happy, the new term still can drive luras anxious which is of course because of the tests! Luras became worried as she wanted to skip the class, as well as to attend the ...
2018-04-20 19:25:49
492
原创 Hdu 6012 Lotus and Horticulture 能看懂的思维
These days Lotus is interested in cultivating potted plants, so she wants to build a greenhouse to meet her research desires. Lotus placed all of the nn pots in the new greenhouse, so all potted plant...
2018-04-20 19:01:54
264
转载 经典博弈
取石子游戏之三种博弈总结2015年04月28日 15:21:51576人阅读 评论(0) 收藏 举报 分类:博弈(2) 转载:http://blog.youkuaiyun.com/xuzengqiang/article/details/77738931、取石子游戏之巴什博弈下面这段来自白白の屋的文章的一段:巴什博弈:只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜...
2018-04-11 17:38:37
181
原创 magical bamboo
In a magical forest, there exists N bamboos that don't quite get cut down the way you would expect.Originally, the height of the ith bamboo is equal to hi. In one move, you can push down a bamboo and ...
2018-04-09 21:06:04
208
原创 kmp循环节 power string
Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-...
2018-04-08 21:07:41
163
原创 没想象中难的substring 有向图判环 拓补· dfs
You are given a graph with n nodes and m directed edges. One lowercase letter is assigned to each node. We define a path's value as the number of the most frequently occurring letter. For example, if ...
2018-04-08 21:00:27
197
原创 详解complete the word
ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears ex...
2018-04-08 19:55:19
804
原创 详解代码 complete the world
ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears ex...
2018-04-08 19:42:14
181
原创 简单易懂的C - Seat Arrangements
Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and y...
2018-04-08 19:34:57
492
原创 1259 通俗易懂的大数据
1259.Problem G. play the guitar Time Limit: 1000 MS Memory Limit: 32768 KB Total Submission(s): 17 Accepted Submissio...
2018-04-04 14:07:38
320
原创 nimk博弈
1253.Problem A. Alice and Bob Time Limit: 1000 MS Memory Limit: 32768 KB Total Submission(s): 11 Accepted Submission(s...
2018-04-02 20:25:07
322
转载 各种博弈取石子
博弈-取石子原创 2014年05月14日 17:28:22标签:博弈 /取石子1022取石子(一)时间限制:3000 ms | 内存限制:65535 KB难度:2描述一天,TT在寝室闲着无聊,和同寝的人玩起了取石子游戏,而由于条件有限,他/她们是用旺仔小馒头当作石子。游戏的规则是这样的。设有一堆石子,数量为N(1<=N<=1000000),两个人轮番取出其中的若干个,每次最多取M个...
2018-03-29 14:48:26
973
原创 经典易懂的二分图最大匹配法, 一个炉石告诉你
DescriptionIf you have played Hearthstone, you will figure out this problem easily. Zhoulaohui is a shut-in so he play Hearthstone everyday. But on the deadline, if he do not study, he would not pass ...
2018-03-28 20:04:49
457
1
原创 666666666素数判断数你快
///六素数快速判断素数int prim( int n ){ if( n == 2 || n == 3) return 1; if( n%6 != 1 && n%6 != 5 ) return 0;///不在六的两侧一定不是 int t = sqrt( n ), i; for( i = 5; i<=t; i+=6) ...
2018-03-27 21:40:55
210
原创 我很菜 简单通俗的做作业
Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after th...
2018-03-23 15:34:49
137
原创 ac的war chess hdu3345
War chess is hh's favorite game: In this game, there is an N * M battle map, and every player has his own Moving Val (MV). In each round, every player can move in four directions as long as he has eno...
2018-03-23 14:53:31
192
原创 AC计算表达式 相信你也秒懂
You may find it’s easy to calculate the expression such as: a = 3 b = 4 c = 5 a + b + c = ? Isn’t it? InputThe first line contains an integer stands for the number of test cases. Each test case start ...
2018-03-20 23:00:16
595
原创 并不高大上d额双线程dp 机器人扫垃圾 其实很简单
Sorry, your browser is not supported. SDNUOJ requires Internet Explorer 8 or greater, please upgrade your browser! 1032.机器人Time Limit: 1000 M...
2018-03-20 21:49:24
313
原创 来迟的素数筛--路利川爱死数学了
#include<cstdio>#include<iostream>#include<cstring>#include<cstdlib>#include<algorithm>#define maxa 1000000using namespace std;int m[maxa];///最大的质因子int a[maxa];///是第几个素数i...
2018-03-18 18:56:25
124
原创 hdu 简单易懂的coins
coinsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2056 Accepted Submission(s): 664Problem Description"Yakexi, this is the best age!" Dong ...
2018-03-18 18:39:31
325
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人