思维
文章平均质量分 54
fanesemyk
这个作者很懒,什么都没留下…
展开
-
codeforces 361B 思维题
B. Levko and Permutationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputLevko loves permutations very much. A permuta原创 2016-04-29 17:32:34 · 496 阅读 · 0 评论 -
Codeforces 797E Array Queries
题目a is an array of n positive integers, all of which are not greater than n.You have to process q queries to this array. Each query is represented by two numbers p and k. Several operations are perform原创 2017-06-18 11:53:57 · 289 阅读 · 0 评论 -
HDU5671-Matrix 区间加减
Problem DescriptionThere is a matrix M that has n rows and m columns (1≤n≤1000,1≤m≤1000).Then we perform q(1≤q≤100,000) operations:1 x y: Swap row x and row y (1≤x,y≤n);2 x y: Swap原创 2017-05-18 22:08:04 · 333 阅读 · 0 评论 -
uva 1591 Data Mining
紫书第四章,最有毒的一题,题目意思有毒,翻译有毒,做法有毒。搬运一篇别人的题解吧,我也是照着别人写的只要暴力所有A、B的组合,看解是不是可行的并找出最优解。 (设有n个元素,每个P占x个字节,每个Q占y个字节。) 怎么判断一个解是否可行呢?想想如果Q连续存储,至少也得消耗n*y个字节,一个AB方案,如果算出的字节小于该值就是不可行的。否则原创 2016-12-16 21:25:50 · 553 阅读 · 0 评论 -
POJ 3320 Jessica's Reading Problem 尺取法 map运用
DescriptionJessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to mast原创 2016-08-02 18:56:30 · 261 阅读 · 0 评论 -
利用特征根方程实现通项公式与递推关系的互换
转载一篇博文,学习了!主要运用在矩阵快速幂中,当给了一个通项公式,而n太大时,需要求出其递推关系,这篇文章讲的很好。基本上,只要看见或者都是这个套路。下面是转载考虑二阶常系数线性齐次递推数列 有方程该方程称为该数列的特征方程,该方程的两个根称为数列的特征根。若特征方程有两个不相等的根则该数列的通项公式为其中为常数,由唯转载 2016-08-04 20:42:50 · 1675 阅读 · 0 评论 -
codeforces 699B One Bomb
DescriptionYou are given a description of a depot. It is a rectangular checkered field ofn × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*").You have on原创 2016-07-20 10:15:06 · 255 阅读 · 0 评论 -
hdu 5676ztr loves lucky numbers
排列组合,打表法。今天学了一个新的函数:next_permutation(a,a+n).具体用法可以百度,大概就是把a全排列,然后返回1(排列成功)或者0(已经是最大)#include#include#include#include#include#include#includeusing namespace std;char temp[20];char temp_b原创 2016-07-15 15:17:01 · 377 阅读 · 0 评论 -
poj 1328 Radar Installation
贪心的典型例题,就是给你n个区间,问最少取多少个点,才能使每个区间内都有点。思路就是把右端点作为第一关键字排序,左端点作为第二关键字排序。然后从左向右遍历,如果有一段的左端点小于目前的右端点,就ans++,同时跳到这一段的右端点。这道题要注意当输出-1的时候千万不要直接break,否则剩下的内容没有读入。#include#include#include#include#includ原创 2016-07-15 15:14:02 · 195 阅读 · 0 评论 -
一道做成傻逼的题HDU2524
给你一个高为n ,宽为m列的网格,计算出这个网格中有多少个矩形,下图为高为2,宽为4的网格. Input第一行输入一个t, 表示有t组数据,然后每行输入n,m,分别表示网格的高和宽 ( n < 100 , m < 100). Output每行输出网格中有多少个矩形. 我的傻逼之处在于,总把原创 2015-11-29 23:52:38 · 469 阅读 · 0 评论 -
WUST OJ 1373: 世界上只有10种人
这道题有点卡,主要是在把数转换成二进制的过程,是很好的递归题目。#include<stdio.h>#include<iso646.h>#include<limits.h>#include<algorithm>#include<math.h>using namespace std;int a[20],k=0;void zhuanhuan(int n){ if((n!=0)and(n!=1))原创 2016-07-15 15:03:06 · 379 阅读 · 0 评论 -
poj1700 Crossing River
http://www.cnblogs.com/yueshuqiao/archive/2011/07/22/2113698.html这篇博客讲的很好,推荐一下。 自己想了一个小时都不会,太菜了。 核心思路是让重的先走。#include<cstring>#include<cmath>#include<iostream>#include<algorithm>using namespace s原创 2016-07-13 19:40:07 · 244 阅读 · 0 评论 -
POJ 3061 Subsequence
这道题有两种做法,一种是比较简单的暴力二分,复杂度为O(nlogn),另一种则是我采取的尺取法。 所谓尺取法,就是像尺子一样一点一点往右移。事实上,对于这道题,我更愿意称它为蚯蚓法:像蚯蚓一样一点点向前移动。 说一下原理:核心是两个指针,移来移去。我们的目的是:使得j指向以i开头的,最短的一个元素(即I到j-1不行)。这样,当i变成I+1时,可以保证I+1到j-1肯定不行。则j就不变或者自增,直原创 2016-07-13 19:36:16 · 248 阅读 · 0 评论 -
利用尾递归实现进制转换
利用尾递归实现进制转换以二进制为例void to_binary(unsigned int n){ int r; r=n%2; if(n>=2) to_binary(n/2); putchar('0'+r); return ;}原理为除二取余法原创 2016-07-11 14:46:00 · 253 阅读 · 0 评论 -
[Gym-101350F] F - Monkeying Around
思维题先预处理,关键在于开一个大小为100000的vector数组,用来记录线段(笑话)的情况。如果笑话在某个点开始了,就把这个编号加进去,反之,如果结束了,就加一个编号的负进去。最后用set维护每个点听到的笑话。#include#include#include#include#include#include#includeusing namespace std;con原创 2017-08-01 20:31:52 · 712 阅读 · 0 评论