题目传送门 /* 题意:对于长度为x的子序列,每个序列存放为最小值,输出长度为x的子序列的最大值 set+线段树:线段树每个结点存放长度为rt的最大值,更新:先升序排序,逐个添加到set中 查找左右相邻的位置,更新长度为r - l - 1的最大值,感觉线段树结构体封装不错! 详细解释:http://blog.csdn.net/u010660276/article/details/46045777 其实还有其他解法,先掌握这种:) */ #include <cstdio> #include &l…
B. Mike and Feet Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/problem/B Description Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standi…
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are…
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are…
题意 n个值代表n个熊的高度 对于size为x的group strength值为这个group(连续的几个熊)中熊的最小的height值 对于x(1<=x<=n) 求出最大的strength值 http://codeforces.com/contest/548/problem/D 思路 我们把每个数作为最小值能最远向左和右用单调栈处理出来,那么可以发现对于x长度的所有group,某个数延伸的区间长度如果大于等于x,则这个数对答案有贡献. 对于样例,我们处理出来后可以观察发现确有此规律: 然后就…
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears…
题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:http://blog.csdn.net/u014357885/article/details/46044287 */ #include <cstdio> #include <algorithm> #include <cstring> #include <iostream…
题目传送门 /* 暴力:每次更新该行的num[],然后暴力找出最优解就可以了:) */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <string> using namespace std; ; const int INF = 0x3f3f3f3f; int a[MAXN][MAXN]; int num[MAXN];…
题目传送门 /* 字符串处理:回文串是串联的,一个一个判断 */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <string> using namespace std; ; const int INF = 0x3f3f3f3f; char s[MAXN]; bool check(int x, int y) { for…
 B. Mike and Fun Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/548/problem/A Description Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m grid, there'…
 A. Mike and Fax Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/548/problem/A Description While Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among th…
 A. Mike and Frog Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/problem/A Description Mike has a frog and a flower. His frog is named Xaniar and his flower is named Abol. Initially(at time 0), height of Xaniar is h1…
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are…
C. Mike and Frog 题意:有一只青蛙和一朵花,分别高度为h1.h2,每浇一次水,h1=(x1*h1+y1)mod m,h2=(x2*h2+y2)mod m.求最少浇多少次后h1=a1,h2=a2? 思路:先遍历m次找到第一次达到a1.a2的次数(若无,则为-1):再找到各自的循环节长度,然后枚举m次循环,判断能否符合题意.注意,可能在y2=0的时候,导致a2只出现一次,后面由于出现0而使得0对任意数取模都为0,则应当特别处理. #include<iostream> #includ…
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are…
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are…
题意 (Codeforces 548D) 对一个有$n$个数的数列,我们要求其连续$x(1\le x\le n)$(对于每个$x$,这样的连续group有若干个)的最小数的最大值. 分析 这是一道用了单调栈的题目,用的贼好.算是第一次应用吧. 我们定义$l_i$为左侧比第$i$个数小的数的下标的最大值(没有就是0):$r_i$就是右侧比第$i$个数小的数的下标的最小值(没有就是$n+1$).这样定义完后,我们会发现,$a_i$是$[a_{l_i+1},a_{r_i-1}]$的最小值,也就是siz…
题意:给出数组arr和一个空数组dst.从arr中取出一个元素到dst为一次操作.问每次操作后dst数组中gcd等于1的组合数.由于数据都小于10^6,先将10^6以下的数分解质因数.具体来说从2开始,将2的倍数全部加2因子(用的vector),3的倍数加3因子.4不是质数,它的倍数不加因子. 还要一个cnt数组记录dst中有几个数是数组下标的倍数. 在放入元素x到dst数组,对于它的每个质因数及质因数间的乘积,看cnt中的量.组合数的增量为dst的sz(size)-(cnt[x的质因数])(即…
题目连接:http://codeforces.com/contest/798/problem/C C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a sequence A = [a1, a2, ..., an] of length n. He considers…
E. Mike and Geometry Problem 题目连接: http://www.codeforces.com/contest/689/problem/E Description Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l, r]) = r - l + 1 to…
C. Mike and Chocolate Thieves 题目连接: http://www.codeforces.com/contest/689/problem/C Description Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! Aside from loving sweet things, thieves from t…
B. Mike and Shortcuts 题目连接: http://www.codeforces.com/contest/689/problem/B Description Recently, Mike was very busy with studying for exams and contests. Now he is going to chill a bit by doing some sight seeing in the city. City consists of n inter…
A. Mike and Cellphone 题目连接: http://www.codeforces.com/contest/689/problem/A Description While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fas…
任意门:http://codeforces.com/contest/689/problem/E E. Mike and Geometry Problem time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Mike wants to prepare for IMO but he doesn't know geometry, so…
Description Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m grid, there's exactly one bear in each cell. We denote the bear standing in column number j of row number i by (i, j).…
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the s…
A. Mike and palindrome time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly onecharacter from the st…
[Codeforces 547A] #include <bits/stdc++.h> #define maxn 1000010 using namespace std; typedef long long ll; bool vis[maxn]; int md, h, a, x, y; int Go(int h, int x, int y){ memset(vis, 0, sizeof vis); int cnt = 0; while(true){ if(vis[h]) return -1; v…
E. Mike and Geometry Problem time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry pro…
C. Mike and Chocolate Thieves time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! As…