
莫队
UCAS王小二
不念过去,不畏未来...
展开
-
P2709 小B的询问【莫队】
题目描述 小B有一个序列,包含N个1~K之间的整数。他一共有M个询问,每个询问给定一个区间[L..R],求Sigma(c(i)^2)的值,其中i的值从1到K,其中c(i)表示数字i在[L..R]中的重复次数。小B请你帮助他回答询问。 输入输出格式 输入格式: 第一行,三个整数N、M、K。 第二行,N个整数,表示小B的序列。 接下来的M行,每行两个整数L、R。 输出格式 M行,每行一...原创 2018-07-24 19:41:40 · 214 阅读 · 0 评论 -
牛客网暑期ACM多校训练营(第一场)J Different Integers【莫队】
题意:给你n个数,q个查询,问你在[L+1,R−1][L+1,R−1][L + 1, R - 1]这段区间之外有多少个不同的数. 分析: 满足莫队思想,直接莫队处理会TLE,把不正规的区间删去,在用莫队处理就行了。 #include <cstdio> #include <cstring> #include <cmath> #include <algo...原创 2018-07-24 20:52:42 · 163 阅读 · 0 评论 -
HDU 6333 Problem B. Harvest of Apples【莫队+组合数】
Problem Description There are n apples on a tree, numbered from 1 to n. Count the number of ways to pick at most m apples. Input The first line of the input contains an integer T (1≤T≤1e5) denotin...原创 2018-08-01 21:37:05 · 181 阅读 · 0 评论