题目链接: https://vjudge.net/problem/POJ-2029 题目大意: 有N棵树在一个n*m的田里,给出每颗树的坐标 用一个s*t的矩形去围,最多能围几棵树 思路: 用二维树状数组求区域和,也可以直接用二维前缀和求解 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<map> #include<set>…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5792 World is Exploding Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others) 问题描述 输入 The input consists of multiple test cases. Each test case begin with an integer n in a sin…
题目描述 给定一个序列$a$,求满足$i<j<k$且$a_i<a_j<a_k$的三元组$(i,j,k)$的个数. 输入 第一行1个数 n 第二行n个数 a_i 输出 一个数,表示能为长者续几秒,由于长者是不朽的, 所以能活很久,不妨将答案对**19260817**取模吧 样例输入 4 1 2 3 4 样例输出 50 题解 离散化+树状数组 枚举中间的数,然后只需要求出左边小于它的数的个数和右边大于它的数的个数即可. 离散化后对于左边和右边分别建立权值树状数组,然后随着指针移动插入/…
During several decades, scientists from planet Nibiru are working to create an engine that would allow spacecrafts to fall into hyperspace and move there with superluminal velocity. To check whether their understanding of properties of hyperspace is…
http://acm.timus.ru/problem.aspx?space=1&num=2062 题意:有n个数,有一个值,q个询问,有单点询问操作,也有对于区间[l,r]的每个数i,使得num[i] + w, num[i*2] + w, num[i*3] + w…… 思路:有树状数组和分块两种做法,对比后分块的速度比较快(暴力的艺术).线段树会超时(可能写法不好). 1.树状数组用到的是单点询问区间修改,我要注意一下其写法...修改为:Add(l, w), Add(r + 1, -w); 查…
Description Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in the 18th century. In order to reward him for his meritorious career in education, Katanobu Matsudaira, the lord of the domain of…
题目 Link 输出序列中有多少个组合 {a1,a2,a3,a4,a5,a6}可以构成一个六边形. 分析 序列每个数都不相等. 所以可以设 a1<a2<a3<a4<a5<a6. 把六边形分解为 4 个三角形, 又可以得出 a1+a2+a3+a4+a5>a6: a1+a2+a3>a6−a5−a4. 在 a4 固定的情况下, a3可以取[a3,a4)之间 所以我们枚举 , 用树状数组维护. Code #include <bits/stdc++.h> usi…
题目描述 给定 \(n,k\) ,求有多少个三元组 \((a,b,c)\) 满足 \(1≤a≤b≤c≤n\)且\(a + b^2 ≡ c^3\ (mod\ k)\). 输入 多组数据,第一行数据组数\(T\). 每组数据两个整数,\(n\)和\(k\). 输出 \(T\)行,每行一个整数,表示满足条件的三元组的个数. 样例 样例输入 1 10 7 样例输出 27 //为什么老被和谐啊 数据范围 \(1≤n,k≤10^5\) \(T≤400\) 时间限制\(4s\) 题解 与其他学校互测,然后做题…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1394 题意:给出一个循环数组,求其逆序对最少为多少: 思路:对于逆序对: 交换两个相邻数,逆序数 +1 或 -1, 交换两个不相邻数 a, b, 逆序数 += 两者间大于 a 的个数 - 两者间小于 a 的个数: 所以只要求出初始时的逆序对数,就可以推出其余情况时的逆序对数.对于求初始逆序对数,这里 n 只有 5e3,可以直接暴力 / 树状数组 / 线段树 / 归并排序: 代码: 1.直接暴力 #i…
3529: [Sdoi2014]数表 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 1399  Solved: 694[Submit][Status][Discuss] Description 有一张N×m的数表,其第i行第j列(1 < =i < =礼,1 < =j < =m)的数值为能同时整除i和j的所有自然数之和.给定a,计算数表中不大于a的数之和. Input 输入包含多组数据.    输入的第一行一个整数Q表示测试点内的数据…