脑子又卡了...来一发set的,STL真心不熟. #include <stdio.h> #include <string.h> #include <iostream> #include <set> using namespace std; ]; set<int>se; set<int>::iterator it1,it,it2; int main() { int i,x,y,num,n,m; scanf("%d%d"…
题目:http://codeforces.com/problemset/problem/356/A 题意:首先给你n,m,代表有n个人还有m次描述,下面m行,每行l,r,x,代表l到r这个区间都被x所击败了(l<=x<=r),被击败的人立马退出游戏让你最后输出每个人是被谁击败的,最后那个胜利者没被 人击败就输出0 思路:他的每次修改的是一个区间的被击败的人,他而且只会记录第一次那个被击败的人,用线段树堕落标记的话他会记录最后一次的,所以我们倒着来修改, 然后因为那个区间里面还包含了自己,在线段…
A. Group of Students time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output At the beginning of the school year Berland State University starts two city school programming groups, for beginners an…
#include <iostream> #include <vector> using namespace std; int main(){ ; cin >> m ; vector<,); ; i <= m ; ++ i) {cin >> c[i];sum+=c[i];} , secondPart = ,firstIndex = , secondIndex =; cin >> x >> y; ,secondIndex =…
数学so奇妙.. 这题肯定会有一个循环节 就是最小公倍数 对于公倍数内的相同的数的判断 就要借助最大公约数了 想想可以想明白 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> #include<vector> using namespace std; #define N 1000100 #defin…
读错题意了..线段树延迟标记 白刷这么多线段树 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> #include<vector> using namespace std; #define N 300010 ],la[N<<]; struct node { int l,r,d; }q[N…
A:超级大水题: 代码: #include<cstdio> #define maxn 105 using namespace std; int n,a[maxn],x,y,ans; int main() { scanf("%d",&n); ; i<=n; i++) { scanf("%d",&x); a[i]=a[i-]+x; ans+=x; } scanf("%d%d",&x,&y); int…
题目链接: B. Xenia and Hamming 题意: 要求找到复制后的两个字符串中不同样的字符 思路: 子问题: 在两串长度是最大公倍数的情况下, 求出一个串在还有一个串中反复字符的个数 CODE: #include <iostream> #include<stdio.h> #include<string> #include<string.h> using namespace std; #define M 1000006 int com[M][26]…
D - Bags and Coins 思路:我们可以这样构造,最大的那个肯定是作为以一个树根,所以我们只要找到一个序列a1 + a2 + a3 .... + ak 并且ak为 所有点中最大的那个,那么我们a1, a2, a3..., ak-1 作为单独的点,其他没有涉及到的点套在ak的里面. 现在问题变成了找出a1, a2, a3, a4, ... , ak. 可以用bitset优化普通dp,因为要找路径,空间开不下,所以需要分段. #include<bits/stdc++.h> #defin…
比赛的时候不知道怎么写... 太弱了. 看了别人的代码,觉得这个是个经典的知识点吧. gcd的巧妙运用 自己想的时候苦苦思考怎么用dp求解. 无奈字符串太长而想不出好的算法. 其实在把a和b字符串都分成以gcd(a,b)长度为单位的字符串时. 设为la=a/gcd(a,b) ,lb=b/gcd(a,b) . 明显可以知道的是gcd(la,lb)==1, 所以la与lb长度的字符串要分别拼接lb和la次才能拼成两个相等的串. 这样就有了解法. for(int i=0;i<lena;i++) dpa…