2016 多校联赛7 Elegant Construction】的更多相关文章

Being an ACMer requires knowledge in many fields, because problems in this contest may use physics, biology, and even musicology as background. And now in this problem, you are being a city architect! A city with N towns (numbered 1 through N) is und…
题意:给2组数据a和b数组,每次有2种操作:(+,l,r,x)把a数组第l个到第r个元素全置为x,(?,l,r)查询[l,r]之间哪些位置满足a[i]>=b[i](i>=l && i<=r)并把这些位置的数量统计 一直想很久,没想到什么有效的方案,直到看到题解才明白过来,原来线段树套平衡树还有这种情况:里面其实不是平衡树,只是有序表. 然后这题就转换为区间查找数对应排名 由于此题不用对2个数组都修改,其中1个b树可作为固定的线段树套有序表以节省时间,另外1个表a树则单纯使…
A stack is a data structure in which all insertions and deletions of entries are made at one end, called the "top" of the stack. The last entry which is inserted is the first one that will be removed. In another word, the operations perform in a…
Mr. Chopsticks is interested in random phenomena, and he conducts an experiment to study randomness. In the experiment, he throws n balls into m boxes in such a manner that each ball has equal probability of going to each boxes. After the experiment,…
Elegant Construction 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer requires knowledge in many fields, because problems in this contest may use physics, biology, and even musicology as background. And now in this prob…
Elegant Construction                                                                         Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)                                                                          …
HDU 5813 Elegant Construction(优雅建造) Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Description 题目描述 Being an ACMer requires knowledge in many fields, because problems in this contest may use physics, biology, and…
Elegant Construction 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer requires knowledge in many fields, because problems in this contest may use physics, biology, and even musicology as background. And now in this prob…
2015 HDU 多校联赛 5363 Key Set 题目: http://acm.hdu.edu.cn/showproblem.php? pid=5363 依据前面给出的样例,得出求解公式 fn = 2^(n-1) - 1, 数据量大,实际就是求幂次方. 可用分治法求解.复杂度O(nlogn) // 分治法求高速幂 #include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; const int M…
2015 HDU 多校联赛 5317 RGCDQ 筛法求解 题目  http://acm.hdu.edu.cn/showproblem.php? pid=5317 本题的数据量非常大,測试样例多.数据量大, 所以必须做预处理.也就是用筛法求出全部的F[x],将全部F[x] 打印出来发现.事实上结果不大,最大的数值是7.所以对于每一个区间询问, 直接暴力求取有多少个 1 2 3 4 5 6 7 就可以,从大到小查找.假设出现2个以上 3-7 的数值,那么最大公约数就是该数字. 假设没有出现两个反复…
题目链接  2016多校1 Problem J 题意  给定两棵相同的树,但是编号方案不同.求第一棵树上的每个点对应的第二棵树上的点.输出一种方案即可. 首先确定树的直径的中点.两棵树相等意味着两棵树的直径相等. 然而直径有很多条,我们任意求出两棵树的各一条直径并不以为着这两条直径是相对应的. 但是直径的中点一定是相对应的. 确定根结点后对整棵树哈希并进行匹配的这个过程是不难的. 当直径长度为偶数时中点有两个,那么最多做$4$次匹配就可以了. 这个哈希函数要好好设计,很容易产生冲突. #incl…
题目链接: Elegant Construction Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others) Problem Description Being an ACMer requires knowledge in many fields, because problems in this contest may use physics, biology, and even…
先讲1007,是一个数位dp,询问一个区间内,各位数的和是一个素数的数字的个数.其实我并不会数位dp,这题直接套用了上次多校lyf队长的dp代码,改了点返回参数没想到直接AC了.代码如下: #include <stdio.h> #include <algorithm> #include <string.h> #include <iostream> #include <vector> #include <queue> #include…
Abandoned country Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1756    Accepted Submission(s): 475 Problem Description An abandoned country has n(n≤100000) villages which are numbered from 1…
Description ?? is practicing his program skill, and now he is given a string, he has to calculate the total number of its distinct substrings. But ?? thinks that is too easy, he wants to make this problem more interesting. ?? likes a character X very…
题目链接 把左括号看成A右括号看成B,推一下就行了.好久之前写的,推到最后发现是一个有规律的序列. #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n; while(scanf("%lld",&n)!=EOF) { ll cnt=,sum=; ;; i++) { if(sum>=n) break; cnt++; sum=sum+cnt; //…
题目链接 宽搜一下就行. #include <iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; int n,m; ][]; ][]={,,-,,,,,-}; ][]; bool check(int x,int y) { ||x>=n||y<||y>=m); ); ; } int prx,pry; struct node { in…
题目链接 #include<cstdio> #include<cstring> #include<algorithm> #include<stack> using namespace std; ]; int cal(int x) { int tx=x; ; while(tx) { &&tx%-pre!=-) ; pre = tx%; tx/=; } return x; } int main() { scanf("%d",&…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5301 题目大意:给你一块由1x1方格组成的矩形区域,其中有且仅有一个坏块,现在你要在上面建矩形的房子, 要求: 1.除坏块以外任何一个1x1方格上都要有房子覆盖 2.任何一座房子都必须有一部分作为矩形区域的边界 3.要使所建房子中面积最大的面积尽量小 要你输出这个所建房子中面积最大的那个房子的面积 解: 大概想一下,面积最大的房子肯定是1*x的长条,因为对任何y来说1*x的长条都可以拼成y*x的长条…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5384 题意:函数f(A, B)定义:A.B为字符串,f(A, B)为A中有多少个不同的B(ex:f("ababa", "aba")==2   f("ababa", "bab")==1),现在给你一组A串,一组B串,问你对每个A串的是多少 解:ac自动机模板题,可以把A串用'z'+1,连成一个串处理起来比较方便 /* * Probl…
题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8506#problem/A problem description As we know, the NTU Final PK contest usually tends to be pretty hard. Many teams got frustrated when participating NTU Final PK contest. So I decide to make the fi…
题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8504#problem/C 代码如下: #include <iostream> #include <algorithm> #include <stdio.h> #include <cstring> #include <queue> #include <bitset> #include <set> #include &l…
题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52310 problem description Define the depth of a node in a rooted tree by applying the following rules recursively: • The depth of a root node is 0. • The depths of child nodes whose parents are with…
题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52305 problem  description In ICPCCamp, there are n cities and (n−1) (bidirectional) roads between cities. The i-th road is between the ai-th and bi-th cities. It is guaranteed that cities are conne…
1001  Another Meaning 题意:字符串A中包含的字符串B可以翻译或不翻译,总共有多少方案. 题解:动规,dp[i]表示A的第i位为止有多少方案. 转移方程: dp[i]=dp[i-1](不翻译) dp[i]+=dp[i-B.size()](翻译i结尾的子串B) 初始条件:dp[0]=1(代表不翻译的这种情况) dp[B.size()]=2(若从A起点开始的子串是B,则有翻译和不翻译两种) //http://acm.hdu.edu.cn/showproblem.php?pid=5…
题目链接 水题,算一下就行. #include <bits/stdc++.h> using namespace std; typedef long long ll; ll x[],y[],z[]; double cal(ll x[]) { ll ans1; ]>=x[]&&x[]<=x[]) ans1=; ]<x[]) ans1=(x[]-x[])*(x[]-x[]); ]>x[]) ans1=(x[]-x[])*(x[]-x[]); return an…
题目链接 很久之前写的了,好像是对拍打表过的,推一下就行了. #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c); ll ans=c*; &&b>=)||(a>=)) printf(); &&b==) printf(&…
题目链接 题目大意就是这个,先找出下标的循环节,再快速幂对20160519取余就行了. 找出下标循环节: #include <cstdio> #include <iostream> using namespace std; int main() { ,a=,b=; for(;;i++) { int t=b; b=(a+b)%; a=t%; &&b==) { printf("%d\n",i); break; } } ; } AC代码: #inclu…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5378 题意:给你一棵n个结点的有根树.因为是有根树,那么每个结点可以指定以它为根的子树(后面讨论的子树都是这个).现在我们把标号从1到n的n个minister派驻到这些结点上面(每个结点派驻一人),并规定任一子树中编号最大的minister 为该子树的领导,问你存在多少个不同的领导 解: 引用官方题解: 可以用求概率的思想来解决这个问题.令以i号节点为根的子树为第i棵子树,设这颗子树恰好有sz[i]…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5372 题意:进行n次操作,操作分两种,0和1,每一个0操作按出现顺序有一个编号(从1开始 0操作 0 x:询问[x, x+i](i为该操作的编号)区间内有多少个完整的线段,并加入线段[x, x+i](线段直接重叠不影响) 1操作 1 x:删除0操作中插入的编号为x的线段,(不影响其他线段,不会重复删除同一线段,删除的线段一定是已经插入的) 解:题目有一个重要的条件:后面插入的线段一定比前面的长.那么…