题目链接:https://nanti.jisuanke.com/t/38223 题意:有一堆火柴构成了一个加减法式子,你可以把火柴重新组合,要求数字个数和原来一样多,每个数字的位数和对应原数字位数一样多,总火柴数量也一样多,要求你构造新的式子算出来的结果最大. 思路:我们用dp[i][j]表示前i个数 用了j根火柴 所能达到的最大值 为此我们需要先预处理两个数组 mx[i][j] mn[i][j] 分别表示 i位数用了j根火柴的最大值/最小值 于是对于dp方程 我们可以得出 dp[i][j]=m…
The Preliminary Contest for ICPC China Nanchang National Invitational 题目一览表 考察知识点 I. Max answer 单调栈+暴力?? J. Distance on the tree 树链剖分 M. Subsequence 思维??…
目录 Contest Info Solutions A. PERFECT NUMBER PROBLEM D. Match Stick Game G. tsy's number H. Coloring Game' I. Max answer J. Distance on the tree K. MORE XOR M. Subsequence Contest Info Practice Link Solved A B C D E F G H I J K L M 8/13 O - - O - - O…
Distance on the tree DSM(Data Structure Master) once learned about tree when he was preparing for NOIP(National Olympiad in Informatics in Provinces) in Senior High School. So when in Data Structure Class in College, he is always absent-minded about…
题目链接:https://nanti.jisuanke.com/t/38228 题目大意:一个区间的值等于该区间的和乘以区间的最小值.给出一个含有n个数的序列(序列的值有正有负),找到该序列的区间最大值. 样例输入: 5 1 2 3 4 5 样例输出: 36 解题思路:如果序列的值全部为正值的话,可以说很简单,用一个单调栈加前缀和就可以了直接a.但是区间中存在负值,这个问题就变得复杂多了. 首先我们可以用两次单调栈,在O(n)的时间内,对于每个a[i]找到一个最大区间[ l[i] , r[i]…
打网络赛 比赛前的准备工作要做好 确保 c++/java/python的编译器能用 打好模板,放在桌面 A. PERFECT NUMBER PROBLEM #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <string> #include <algorithm> #include <set> #include…
Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to find the max value of the intervals in her array. Can you h…
Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to find the max value of the intervals in her array. Can you h…
题面 题意:一个5e5的数组,定义一个区间的值为 这个区间的和*这个区间的最小值,注意数组值有负数有正数,求所有区间中最大的值 题解:如果全是正数,那就是原题 POJ2796 单调栈做一下就ok 我们现在有负数,考虑这段区间,他的和必须是负数,由于导致和为负数,最小值一定也是负数, 那对于这样一个和为负的区间进行扩展的时候,遇见下一个数,是负数,我们一定会扩展,无论这个负数大小 遇见下一个是正数,如果和没有变正,那就可以继续扩展下去(不更新答案罢了) 所以我们对于那些和为负的区间,单独统计一下答…
A. PERFECT NUMBER PROBLEM 题目链接:https://nanti.jisuanke.com/t/38220 题意: 输出前五个完美数 分析: 签到.直接百度完美数输出即可 #include<bits/stdc++.h> #define ios std::ios::sync_with_stdio(false) , std::cin.tie(0) , std::cout.tie(0) #define sd(n) scanf("%d",&n) #d…
Max answer Alice has a magic array. She suggests that the value of a interval is equal to the sum of the values in the interval, multiplied by the smallest value in the interval. Now she is planning to find the max value of the intervals in her array…
目录 Contest Info Solutions A. Attack B. Polynomial E. Interesting Trip F. Sequence G. Winner H. Another Sequence I. Hamster Sort J. Prefix K. A Good Game Contest Info Practice Link Solved A B C D E F G H I J K 9/11 O O - - Ø O Ø O Ø O O O 在比赛中通过 Ø 赛后通…
比赛链接https://www.jisuanke.com/contest/3098?view=challenges B题 拉格朗日插值 题意  T组输入.一个n次多项式 f(x) ,每项的系数不知道,只知道f(0),f(1)..f(n) 的值,m个询问,L,R.计算$\sum_{i=L}^{R}f(i)\quad mod(9999991)$ $(1\leq T\leq 5) $ $(1\leq n\leq 1000) $ $(1\leq m\leq 2000) $ $(1\leq L\leq R…
题意:给你一个长度为$n$的数组,定义函数$f(l,r)=a_{l} \oplus a_{l+1} \oplus...\oplus a_{r}$,$F(l,r)=f(l,l)\oplus f(l,l+1)\oplus ...\oplus f(l,r)\oplus f(l+1,l+1)\oplus ...f(l+1,r)\oplus ...\oplus f(r,r)$,有两种操作,第一种将数组中某个元素$a[x]$变为$y$,第二种计算$F(l,r)$的值. 思路:打表后发现只有当$l$和$r$同…
南昌邀请赛网络赛 D.Match Stick Game 题目传送门 题目就会给你一个长度为n的字符串,其中\(1<n<100\).这个字符串是一个表达式,只有加减运算符,然后输入的每一个字符都是可以由若干个火柴棒拼接而成的. 现在在不改变每个数的位数,数的总数以及运算符的个数的前提下,可以对火柴棒重新拼接.询问最后可以拼接出来的最大值是多少. 这个自己看下题目可能要清楚一些= =   每一个字符都是由若干个火柴棒构成的,我们可以考虑类似于背包的思路来求解. 因为每个数的位数最后都没发生变化,所…
目录 ACM ICPC China final G Pandaria ACM ICPC China final G Pandaria 题意:给一张\(n\)个点\(m\)条边的无向图,\(c[i]\)代表点\(i\)的颜色,每条边有一个权值 现在有q个询问如下 u w代表从点u出发,每次只能走权值不超过w的边,经过的颜色中次数最多的是哪种颜色,若有多种,输出编号最小的. $ 1<=n<=1e5$ $ 1<=m,q<=2e5$ $ 1<=c_i<=n$ $ 1<=w…
We call a string as a 0689-string if this string only consists of digits '0', '6', '8' and '9'. Given a 0689-string $s$ of length $n$, one must do the following operation exactly once: select a non-empty substring of $s$ and rotate it 180 degrees. Mo…
BaoBao has just found a grid with $n$ rows and $m$ columns in his left pocket, where the cell in the $j$-th column of the $i$-th row (indicated by $(i, j)$) contains an arrow (pointing either upwards, downwards, leftwards or rightwards) and an intege…
题目:https://nanti.jisuanke.com/t/41352 思路:约瑟夫环 由题意得第k张牌即求 k 为 第几个 报数为m+1 的单位 用队列模拟即可 #include<bits/stdc++.h> using namespace std; ]; int main() { int T; scanf("%d",&T); int n,m,c; while(T--) { ; scanf("%d%d%d",&n,&m,&a…
题目:https://nanti.jisuanke.com/t/41349 思路:dijkstra最短路径 先以 fire-fighting hero为起点 跑一遍dijkstra 建立 起点 p 并与各 fire-fighting point 建立 权为0的边 跑完dijkstra  dis[i]为 p到point i的最短路径 即各 fire-fighting point 到 point i 的最短路径中的最小值 最后将两遍dijkstra 的dis[ ]中的最大值进行比较即可 #inclu…
题意: 给定一个二进制表示的n,让你找满足如下要求的数对(i,j)的个数 $0 \leqslant j \leqslant i \leqslant n$ $ i & n = i $ $ i & j = 0 $ 其中&代表按位与 题解: 打表发现对于单个i满足上述规律的j的数量为$2^{(num \ of \ 0 \ in(i)_2)}$ 因此对着n的二进制可以从后往前dp计算每一位能够贡献出多少个i,这些i能够贡献出多少0 #include <algorithm> #i…
题意: 给你n个盘子,这n个盘子里面分别装着1!到n!重量的食物,对于每一个询问k,找出一个最短的区间,使得区间和 mod 998857459 大于或等于k 盘子数量 n<=1e5 询问次数 m<=1e4 题解: 坑点在于此题模数998857459=4*773*2803 是个合数,因此任何a>=2803 a!=0 因此,只需考虑非0的盘子作为端点,暴力枚举$(max(n,2802))^2$个区间. 我使用的方式是记录阶乘取模非0节点的值和位置,然后求前缀和 再枚举左右端点,记录区间和取模…
QSC and Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 859    Accepted Submission(s): 325 Problem Description Every school has some legends, Northeastern University is the same. Enter…
odd-even number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 388    Accepted Submission(s): 212 Problem Description For a number,if the length of continuous odd digits is even and the length…
#1636 : Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the first living being and the creator of the sky and the earth. He woke up from an egg and split the egg into two parts: the sky and the earth. At the begi…
题目链接:https://codeforc.es/contest/1070/problem/J 题意:给出一个长度为 k 的字符串,选出 n 个和 m 个不同位置的字符构成两个字符串,使得两个字符串相同字母的对数最少. 题解:在最优解的情况下,两个字符串相同的字母只有一个(假设有两种相同的字母,调换他们的位置变得只有一种相同字母的时候更优,可以自行草稿纸上写下不等式证明),可以枚举相同的字母,剩下的字母做 01 背包判断可以构成的最大长度即可. #include <bits/stdc++.h>…
贴贴大佬的计蒜客题解: The Preliminary Contest for ICPC China Nanchang National Invitational and International Silk-Road Programming Contest 离线处理,运用树链剖分让LCA跑快点 关键是把n-1条边,和m条询问边存起来 然后按边权值W进行升序: 这样在计数询问的时候我们从小到大计数: 每条边只会被记一次且从小到大,这样就不用担心当前计数会受上一计数更新时的影响: 每次把小于等于当…
dp--2019南昌网络赛B-Match Stick Game Xiao Ming recently indulges in match stick game and he thinks he is good at it. His friend Xiao Jun decides to test him. Xiao Jun gives him an expression of length , made by match sticks and asks him to calculate the m…
In Dapu, a rain-drenched rural outpost in the heart of China's grain basket, a farmer grows crops that she wouldn't dare to eat. A state-backed chemicals factory next to her farm dumps wastewater directly into the local irrigation pond, she says, and…
解题过程 中午吃饭比较晚,到机房lfw开始发各队的账号密码,byf开始读D题,shl电脑卡的要死,启动中...然后听到谁说A题过了好多,然后shl让blf读A题,A题blf一下就A了.然后lfw读完M题(shl的电脑终于打开了,然后输入密码,密码错误...自闭),说AC 自动机板题,然后找板子,,,突然发现自己读错题目.后来不知道怎么A的.shl copy了一遍密码终于登上账号.然后lfw一个人用单调栈和前缀和st表A掉了I题:byf 秒了H题: shl和byf读j题,读完吧题意告诉lfw,lf…