hdu6667
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
###nameRoundgod and Milk Tea
###decriptionRoundgod is a famous milk tea lover at Nanjing University second to none. This year, he plans to conduct a milk tea festival. There will be n classes participating in this festival, where the ith class has ai students and will make bi cups of milk tea.
Roundgod wants more students to savor milk tea, so he stipulates that every student can taste at most one c ...
hdu5634
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
nameRikka with Phi
decriptionRikka and Yuta are interested in Phi function (which is known as Euler’s totient function).Yuta gives Rikka an array A[1..n] of positive integers, then Yuta makes m queries.There are three types of queries:
1lrChange A[i] into φ(A[i]), for all i∈[l,r].
2lrxChange A[i] into x, for all i∈[l,r].
3lrSum up A[i], for all i∈[l,r].Help Rikka by computing the results of queries ...
splay
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990//初始化时要初始化tot和stk[0]const int N=3e5+3;int c[N][2],f[N],stk[N],nie=N-1,tot;//树结构,几乎不用初始化int nu[N],w[N],cov[N];//值和懒惰标记结构,一定要赋初值,int sz[N],mx[N],mi[N]; long long s[N];//区间结构,不用赋予初值,inline void pushfrom(int u,int son){// assert(s ...
线段树
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869#define ml ((l+r)>>1)#define mr (ml+1)const int maxn=3e5+5;int a[maxn];int ls[maxn*2],rs[maxn*2],tot;// 树结构int cov[maxn*2];// 懒惰标记结构ll sum[maxn*2];int mi[maxn*2],mx[maxn*2];// 区间结构inline void modify(int&u,int l,int r,int cov_){// 这个函数要注意重写 if(cov_!=-1)& ...
hdu6647
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
###nameBracket Sequences on Tree
###decriptionCuber QQ knows about DFS on an undirected tree, he’s sure that you are familiar with it too. In case you are not, Cuber QQ is delighted to share with you a snippet of pseudo code:
function dfs(int cur, int parent): print(‘(‘) for all nxt that cur is adjacent to: dfs(nxt, cur) print(‘)’)
You might notice that Cuber QQ print a “(“ when entering a no ...
bzoj4999
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
nameThis Problem Is Too Simple!
description给您一颗树,每个节点有个初始值。现在支持以下两种操作:
C i x(0<=x<2^31) 表示将i节点的值改为x。
Q i j x(0<=x<2^31) 表示询问i节点到j节点的路径上有多少个值为x的节点。
input第一行有两个整数N,Q(1 ≤N≤ 100,000;1 ≤Q≤ 200,000),分别表示节点个数和操作个数。下面一行N个整数,表示初始时每个节点的初始值。接下来N-1行,每行两个整数x,y,表示x节点与y节点之间有边直接相连(描述一颗树)。接下来Q行,每行表示一个操作,操作的描述已经在题目描述中给出。
output对于每个Q输出单独一行表示所求的答案。
sample input5 610 20 30 40 501 21 33 43 5Q 2 ...
hdu4578
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
###nameTransformation
###descriptionYuanfang is puzzled with the question below:There are n integers, $a_1, a_2, …, a_n$. The initial values of them are 0. There are four kinds of operations.Operation 1: Add c to each number between ax and ay inclusive. In other words, do transformation $a_k=a_k+c$, k = x,x+1,…,y.Operation 2: Multiply c to each number between ax and ay inclusive. In other ...
uoj119
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
###name决战圆锥曲线
###descirption数学考试,一道圆锥曲线的题难住了你,你开始疯狂地笔算。但是,这题实在太难,于是你决定每种思路多尝试尝试。
你的思维过程可以转化为如下过程:有一个随机数产生器,有个内部变量 x 初始时为 x0,每次产生随机数时它会将 x 变为 (100000005x+20150609)mod998244353,然后返回 ⌊x100⌋。(amodb 表示 a 除以 b的余数,该运算的优先级高于加减法。⌊α⌋表示 α向下取整后的结果。)初始时有 n个点,分别编号为 1,…,n,按编号从小到大顺序生成第 i个点的坐标:把横坐标赋为 i。产生一个随机数 y^,把纵坐标赋为 y^mod100001。有 m个操作,表示你的思路过程。操作共有三种:C:按顺序产生随机数 p^,y^,令 p=p^modn+1,y=y^mod100001,然后把第 p ...
P4121[wc2005]
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
###name双面棋盘
###descirption佳佳有一个 n 行 n 列的黑白棋盘,每个格子都有两面,一面白色,一面黑色。佳佳把棋盘平放在桌子上,因此每个格子恰好一面朝上,如下图所示:我们把每行从上到下编号为 1,2,3,……,n,各列从左到右编号为 1,2,3,……,n,则每个格子可以用棋盘坐标(x,y)表示。在上图中,有8个格子黑色朝上,另外17 个格子白色朝上。如果两个同色格子有一条公共边,我们称这两个同色格子属于同一个连通块。上图共有 5 个黑色连通块和 3 个白色连通块。佳佳可以每分钟将一个格子翻转(即白色变成黑色,黑色变成白色),然后计算当前有多少个黑色连通块和白色连通块,你能算得更快吗?
###input输入文件的第一行包含一个正整数 n,为格子的边长。以下 n 行每行 n 个整数,非 0 即 1,表示初始状态。0 表示白色,1 表示黑色。下一行包含一个整数 m,表示操 ...
Codeforces Round #172 (Div. 1) - D
nexthexonextbutterflyvolantisyearnyiliashokaindigoapollolandscapecactusmateryicarusfluidmaterial
namek-Maximum Subsequence Sum
descirptiontime limit per test 4 secondsmemory limit per test 256 megabytesConsider integer sequence $a_1, a_2, …, a_n$. You should run queries of two types:The query format is “0 i val”. In reply to this query you should make the following assignment: $a_i$ = val.The query format is “1 l r k”. In reply to this query you should print the maximum sum of at most k no ...