小A的糖果 思路: for循环贪心: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 #define ll long long ll ai[maxn],n,m,ans; inline void in(ll &now) { ; ')Cget=getchar(); ') { now=now*+Cget-'; Cget=getchar(); } } int main() { in(n),in(m);…
小B的询问 思路: 水题: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 50005 #define ll long long int bel[maxn]; struct QueryType { int l,r,id; bool operator <(const QueryType pos)const { if(bel[l]==bel[pos.l]) return r<pos.r; else retur…
小A和uim之大逃离 II 思路: spfa: 代码: #include <bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f struct NodeType { int x,y,k; NodeType(int x_,int y_,int k_):x(x_),y(y_),k(k_){} NodeType(){} }; ]={,-,,,}; ]={,,,,-}; ][][]; ][]; queue<NodeType>q…
题目描述 某校大门外长度为L的马路上有一排树,每两棵相邻的树之间的间隔都是1米.我们可以把马路看成一个数轴,马路的一端在数轴0的位置,另一端在L的位置:数轴上的每个整数点,即0,1,2,……,L,都种有一棵树. 由于马路上有一些区域要用来建地铁.这些区域用它们在数轴上的起始点和终止点表示.已知任一区域的起始点和终止点的坐标都是整数,区域之间可能有重合的部分.现在要把这些区域中的树(包括区域端点处的两棵树)移走.你的任务是计算将这些树都移走后,马路上还有多少棵树. 输入输出格式 输入格式: 输入文…
题目背景 数学是火,点亮物理的灯:物理是灯,照亮化学的路:化学是路,通向生物的坑:生物是坑,埋葬学理的人. 文言是火,点亮历史宫灯:历史是灯,照亮社会之路:社会是路,通向哲学大坑:哲学是坑,埋葬文科生.——小A 题目描述 小A“刷题”十分猖狂,明目张胆地“刷题”.他现在在小书童里发现了n样他喜欢的“题目”,每“题”都有他的需要时间,而老师布置了m项作业,每项作业都有它的需要时间及分值,老师规定k分以上算及格.小A只剩r个单位时间,他想在及格的基础上更多地“刷题”. 输入输出格式 输入格式: 第一…
题目描述 随着智能手机的日益普及,人们对无线网的需求日益增大.某城市决定对城市内的公共场所覆盖无线网. 假设该城市的布局为由严格平行的129 条东西向街道和129 条南北向街道所形成的网格状,并且相邻的平行街道之间的距离都是恒定值 1 .东西向街道从北到南依次编号为0,1,2…128 , 南北向街道从西到东依次编号为0,1,2…128 . 东西向街道和南北向街道相交形成路口,规定编号为x 的南北向街道和编号为y 的东西向街道形成的路口的坐标是(x , y ). 在 某 些 路口存在一定数量的公共…
松江1843路 思路: 三分: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 #define ll long long struct DataType { ll pi,val,sumval,sumpi; bool operator<(const DataType pos)const { return pi<pos.pi; } }; struct DataType ai[maxn]; ll…
矩阵取数游戏 思路: dp+高精: 代码: #include <bits/stdc++.h> using namespace std; #define ll long long struct Int { int len; ]; Int() { len=,ai[]=; } void Count(int pos) { len++; ) Count(pos/); } void operator=(int pos_) { int pos=pos_; len=,Count(pos); ;i<len…
红色的幻想乡 思路: 线段树+容斥原理: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 #define maxm maxn<<2 #define ll long long class TreeType { private: int L[maxm],R[maxm],mid[maxm],dis[maxm]; public: void build(int now,int l,int r) { L…
妖梦拼木棒 思路: 神特么题: 代码: #include <bits/stdc++.h> using namespace std; #define mod 1000000007LL int n,m; ],ans; inline void in(int &now) { ; ')Cget=getchar(); ') { now=now*+Cget-'; Cget=getchar(); } } int main() { in(n);int pos; ;i<=n;i++) in(pos)…