http://codeforces.com/gym/101138/problem/A 感觉有一种套路就是总长度 <= 某一个数的这类题,大多可以分块 首先把集合串按长度分块,对于每一个询问串, 在 > magic的big集合里,因为最多sqrtn个,可以暴力枚举每一个,然后暴力枚举询问串的每一个长度是其的子串,判断是否相等 在 <= magic的small集合里,枚举每一个长度是magic, magic-1, magic-2, magic-3........1的字符串,然后看看是否在sm…
A. DZY Loves Hash time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output DZY has a hash table with p buckets, numbered from 0 to p - 1. He wants to insert n numbers, in the order they are given, i…
题目连接:hdu_5085_Counting problem 题意:给你一个计算公式,然后给你一个区间,问这个区间内满足条件的数有多少个 题解:由于这个公式比较特殊,具有可加性,我们考虑讲一个数分为两个部分,这样就可以用莫队的思想均摊时间复杂度,将9位数分为一个4位和一个5位,这里我感觉sqr为10000 速度比较快.然后如果b小于sqr,那么直接暴力就行,如果b大于sqr,那么我们要把a和b都分为头部和尾部(注意是闭区间,a需要减1),如果a小于sqr,那么他的头部就为0,然后计算0-a的尾部…
题目链接:http://poj.org/problem?id=3468 A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 144616   Accepted: 44933 Case Time Limit: 2000MS Description You have N integers, A1, A2, ... , AN. You need to deal with…
一.题目 D. Yet Another Subarray Problem 二.分析 公式的推导时参考的洛谷聚聚们的推导 重点是公式的推导,推导出公式后,分块是很容易想的.但是很容易写炸. 1 有些地方容易溢出,这和设置的无穷大的值的大小也有关. 2 如果每次确定了边界$r$,那么在枚举$m$的余数的情况时,一定注意到比$r$大的还不能枚举. 三.AC代码 1 #include <bits/stdc++.h> 2 3 using namespace std; 4 #define Min(a, b…
题解:分块 解题报告: 是个板子题呢qwq 没什么可说的,加深了对分块的理解趴还是 毕竟这么简单的板子题我居然死去活来WA了半天才调出来,,,哭了QAQ 还是说下我错在了哪几个地方(...是的,有好几个,,,太生气了太弱了! 第一个是要意识到并不是√n*(√n+1)一定>n...我我我我我卡在这儿调了半天QAQ 第二个是未满一个区间的修改的时候出来要暴力搞掉所有a[i]以外还要sum[i]+=add*len鸭!这里开始也没有想到QAQ 没了,放代码qwq #include<iostream&g…
题目链接 题意翻译 给你一个长度为 \(n\) 的字符串,\(m\) 次询问. 问两个相同长度的子串是否匹配. 我们称两个子串是匹配的,当且仅当其满足: 其中一个子串的字母可替代另一个子串的字母 例如,我们称 \(orzzz\) 和 \(yzkkk\) 是匹配的,因为其满足交换条件: \(o\) -> \(y\) \(r\) -> \(z\) \(z\) -> \(k\) 所以它们是匹配的. 同时输入中前两个为子串起点,最后一个为子串长度. Solution 先补充一个知识点,子串哈希的…
Description You have \(N\) integers, \(A_1, A_2, ... , A_N\). You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask for the sum of numbers in a given i…
A string is binary, if it consists only of characters "0" and "1". String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six sub…
A string is binary, if it consists only of characters "0" and "1". String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six sub…
Hash function From Wikipedia, the free encyclopedia   A hash function that maps names to integers from 0 to 15. There is a collision between keys "John Smith" and "Sandra Dee". A hash function is any function that maps data of arbitrar…
Codeforces 25E Test E. Test Sometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings - input data to his problem is one string. Bob has 3 wrong solutions to this problem. The first gives…
哈希(hash)函数 hSet 命令/方法/函数 Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned. 添加一个VALUE到HASH中.如果VALUE已经存在于HASH中,则返回FALSE. Parameters key hashKey value Return value LONG 1 if value didn't exist and was added…
浅谈分块:https://www.cnblogs.com/AKMer/p/10369816.html 题目传送门:http://poj.org/problem?id=3468 分块裸题.对于每个块记录权值和与加标记即可.详情见代码. 时间复杂度:\(O(n\sqrt{n})\) 空间复杂度:\(O(n)\) 代码如下: #include <cmath> #include <cstdio> using namespace std; typedef long long ll; cons…
The Problem to Slow Down You Time Limit: 20000ms Memory Limit: 524288KB This problem will be judged on CodeForcesGym. Original ID: 100548G64-bit integer IO format: %I64d      Java class name: (Any)   After finishing his homework, our problem setter F…
题目链接 : https://www.acwing.com/problem/content/description/142/ Hash + 二分 #include <bits/stdc++.h> using namespace std; ; typedef unsigned long long ull; ; ull p[maxn],h[maxn]; int sa[maxn],rank[maxn],height[maxn]; char str[maxn]; int n ; ull get(int…
原table2excel代码 /* * 采用jquery模板插件——jQuery Boilerplate * * Made by QuJun * 2017/01/10 */ //table2excel.js ; (function ($, window, document, undefined) { var pluginName = "table2excel", rootPath = "http://" + window.location.host, current…
E. Test time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Sometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings — input data…
代码出处:A simple string hashmap in C  https://github.com/petewarden/c_hashmap main.c (main2是官方源代码,main是博主写的代码,实现了String类型及Char类型的存取,看官可以根据以下代码触类旁通,限于博主的c语言 功底有限,此处的实现仅为poc代码,不保证严谨性以及稳定性,如果使用到生产环境请多斟酌,测试,如果你有更完善的代码分享,将感激不尽) /* * A unit test and example o…
redis入门笔记(1) 1. Redis 简介 •Redis是一款开源的.高性能的键-值存储(key-value store).它常被称作是一款数据结构服务器(data structure server).Redis的键值可以包括字符串(strings)类型,同时它还包括哈希(hashes).列表(lists).集合(sets)和 有序集合(sorted sets)等数据类型. 对于这些数据类型,你可以执行原子操作.例如:对字符串进行附加操作(append):递增哈希中的值:向列表中增加元素:…
比赛链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=44704#overview 题目来源: ZOJ Monthly, June 2012 on June 24 Wine93有话说: 无话可说~~~ 转下wuyiqi巨巨的题解:http://www.cnblogs.com/wuyiqi/archive/2012/06/25/2562806.html     ID Origin Title   6 / 27 Problem A Z…
Codeforces Round #112 (Div. 2) C. Another Problem on Strings 题意 给一个01字符串,求包含\(k\)个1的子串个数. 思路 统计字符1的位置,两端用0填充. \(k=0\)需要特判. 代码 C. Another Problem on Strings D. Beard Graph 题意 一棵\(N(N \le 10^5)\)个点的树,每条边被染成黑色或白色,初始都是黑色. \(M(M \le 3 \times 10^5)\)次操作,要么…
        Web电子商务网(三层)V2.0源码 2014-07-31   [VS2010] 源码介绍: Web电子商务网(三层)V2.0源码 源码描述: 一.源码特点     采用三层架构开发,购物车功能 二.功能介绍     前台集成了产品在线展示,用户注册.在线调查.在线投稿     后台有类别管理\图书管理\订单管理\会员管理\配送范围管理\邮件列表\广告管理\友情链接管理等     后台添加图书时自动生成缩略图和文字水印     主要参考了petshop的设计架构.使用了Asp.n…
Description Sometimes it is hard to prepare tests for programming problems. Now Bob is preparing tests to new problem about strings — input data to his problem is one string. Bob has 3 wrong solutions to this problem. The first gives the wrong answer…
Q1: 520. Detect Capital Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA…
缓存是最直接有效提升系统性能的手段之一.个人认为用好用对缓存是优秀程序员的必备基本素质. 本文结合实际开发经验,从简单概念原理和代码入手,一步一步搭建一个简单的二级缓存系统. 一.通用缓存接口 1.缓存基础算法 (1).FIFO(First In First Out),先进先出,和OS里的FIFO思路相同,如果一个数据最先进入缓存中,当缓存满的时候,应当把最先进入缓存的数据给移除掉.(2).LFU(Least Frequently Used),最不经常使用,如果一个数据在最近一段时间内使用次数很…
Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [ ["ate","eat","tea"], ["nat","…
-------------------------------ODbgScript original pluginhttp://github.com/odbgscript------------------------------- 1. About OllyScript and ODbgScript2. Status 2.1 What's new?3. Documentation 3.1 Language 3.1.1 Reserved variables 3.1.2 Commands 3.2…
[抄题]: 给出一个字符串数组S,找到其中所有的乱序字符串(Anagram).如果一个字符串是乱序字符串,那么他存在一个字母集合相同,但顺序不同的字符串也在S中. 对于字符串数组 ["lint","intl","inlt","code"] 返回 ["lint","inlt","intl"] [思维问题]: [一句话思路]: key是相同的哈希值(重要),value是不…
This is a list of some of the more commonly known problems that are NP-complete when expressed as decision problems. As there are hundreds of such problems known, this list is in no way comprehensive. Many problems of this type can be found in Garey…