NCD 2019 C. Hasan and his lazy students】的更多相关文章

题意:给你一组数,求最长的严格上升子序列及个数(mod 1e9+7) 题解:用动态规划来求LIS,记\(dp[i]\)是数组中第i个位置上的数的LIS最优解,我们遍历一遍原数组,然后找i位置前的LIS,如果\(a[j]<a[i]\)并且\(dp[j]+1>dp[i]\)那么当前i位置的最优解就应该更新成\(dp[j]+1\).然后我们再记一个\(res[i][length]\),表示i位置上长度为length的LIS的个数.最后统计一下长度最长的子序列有多少个就行了. 代码: #include…
题意 :给你两个指数类型的数\(A^m\)和\(B^n\),比较他们的大小.保证底数和指数中最多只有一个为0. 题解 :题目数据非常大,肯定不能直接比较.由换底公式和\(Log\)函数的性质我们知道:\(LogA^m=mLogA\),又因为\(Log\)函数是单增的,我们便可以用它来进行大小的比较.这里要注意当底数为0的时候,指数为0可以不用管.还有要记住!!! double类型比较大小会出现精度的问题,不能直接比,要用一个eps!!! 代码: #include <iostream> #inc…
题意:给你n个数,有m次操作,每次使得两个数相连接,询问q次,问某两个数是否连接在一起. 题解:这其实是一道并查集的裸题,这里就不再多说了,写个路径压缩的find函数即可. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <stack> #include <que…
Description Mr. O'Cruel is teaching Math to ninth grade students. Students of course are very lazy, so they do not like to do their homework. On the other side, Mr. O'Cruel doesn't like lazy students. Recently Andrew failed to do his homework again,…
题目链接:https://nanti.jisuanke.com/t/40852 题意:给定一个01串s,进行m次操作,|s|<=1e6,m<=5e5 操作有两种 l r 0,区间[l,r]升序排序 l r 1,区间[l,r]降序排序 输出m次操作后的串s 官方解析: 维护区间1的个数,区间0的个数=区间长度-区间1的个数,完成区间赋值操作并更新即可. 个人思路: 线段树的操作都是log(n),如果带了lazy标记,就可以小于log(n),不必查询到每个点.例如将[1,3]都置为1,只用将t[2…
在使用EF的过程中,导航属性的lazy load机制,能够减少对数据库的不必要的访问.只有当你使用到导航属性的时候,才会访问数据库.但是这个只是对于单个实体而言,而不适用于显示列表数据的情况. 这篇文章介绍的是,使用Lazy<T>来提高显示列表页面的效率. 这里是相关的源代码 PerformanceTest.zip 阅读目录: 一.问题的描述 二.数据表和EF实体介绍 三.lazy load的性能 四.使用StudentExtensionRepository来提高效率 五.进一步改进,使用St…
Description A math instructor is too lazy to grade a question in the exam papers in which students are supposed to produce a complicated formula for the question asked. Students may write correct answers in different forms which makes grading very ha…
Description A math instructor is too lazy to grade a question in the exam papers in which students are supposed to produce a complicated formula for the question asked. Students may write correct answers in different forms which makes grading very ha…
Problem Description A math instructor is too lazy to grade a question in the exam papers in which students are supposed to produce a complicated formula for the question asked. Students may write correct answers in different forms which makes grading…
  Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3721   Accepted: 1290 Description A math instructor is too lazy to grade a question in the exam papers in which students are supposed to produce a complicated formula for the question ask…