Description You are given two integers N,C and two integer sequences a and b of length N. The sequences are indexed from 1 to N. Please solve the following equation for x: where |v| means the absolute value of v. Input The first line contains an inte…
HDU6578 2019HDU多校训练赛第一场 1001 (dp) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6578 题意: 你有n个空需要去填,有m个限制,每次限制要求在区间[l,r]内不同的点的个数是为x个,问你填完这n个空的并且满足限制的方案数 题解: 定义\(dp[i][j][k][t]\)表示在区间填完前t个位置后,{0,1,2,3}这四个数字最后一次出现的位置为i,j,k,t的方案数 滚动数组优化掉第一维后,我们转移如下 dp[p]…
HDU6579 2019HDU多校训练赛第一场1002 (线性基) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6579 题意: 两种操作 1.在序列末尾添加一个数 2.查询区间异或最大值 强制在线 题解: 暴力的做法可以用数据结构维护区间线性基,但肯定过不了. 贪心地维护序列的前缀线性基 (上三角形态),对于每个线性基,将出现位置靠右的数 字尽可能地放在高位,也就是说在插入新数字的时候,要同时记录对应位置上数字的出现位 置,并且在找到可以插入的位…
源代码见文末 部分源代码: % 符号变量 两种表达方式 a=sym('a'); class(a); syms b; b; % 符号常量 c=sym('); c; % 符号表达式 三种表达方式 f1='3*x+4'; % char类型,但是可以参与运算.所以这种形式是可以直接用的,比较方便 syms x f2=3*x+4; % sym类型 f3=sym('3*y+4'); % sym类型 % 符号四则运算 fadd1 = f1 + f2; fmu1 = f1*f2; % 符号表达式的化解 syms…
P1689 方程求解 题目描述 给一个方程,形如X+Y=Z或X-Y=Z.给出了其中两个未知数,请求出第三个数.未知数用‘?’表示,等式中也许会出现一些多余的空格. 输入输出格式 输入格式: 一行,方程. 输出格式: ‘?’代表的值 输入输出样例 输入样例#1: 复制 样例输入1 1+2=? 样例输入2 3 +? = 2 输出样例#1: 复制 样例输出1 3 样例输出1 -1 说明 0<=X,Y,Z<1,000,000,000 模拟 #include<cstdio> #include…
P1689 方程求解 题目描述 给一个方程,形如X+Y=Z或X-Y=Z.给出了其中两个未知数,请求出第三个数.未知数用‘?’表示,等式中也许会出现一些多余的空格. 输入输出格式 输入格式: 一行,方程. 输出格式: ‘?’代表的值 输入输出样例 输入样例#1: 复制 样例输入1 1+2=? 样例输入2 3 +? = 2 输出样例#1: 复制 样例输出1 3 样例输出1 -1 说明 0<=X,Y,Z<1,000,000,000 思路:模拟 #include<cstdio> #incl…
layout: post title: 2019牛客暑期多校训练营(第五场)G - subsequeue 1 (一题我真的不会的题) author: "luowentaoaa" catalog: true tags: mathjax: true - ACM-ICPC 题意 给你两个由数字组成的字符串\(S\),\(T\) 长度为\(1e3\),问你S中有多少个子序列的值大于字符串T: 思路 首先在比赛的时候一眼确定是\(N^2\) 复杂度的DP,但是想了两三个小时却没想到怎么转移,各种…
HDU6621 K-th Closest Distance HDU2019多校训练第四场 1008(主席树+二分) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6621 题意: 给你n个数,有m次询问 每次问你在区间[l,r]内 第k小的|\(a_i-p\)|是多少 题解: 主席树+二分 每次二分答案 如果p+mid到p-mid的值的个数大于k个的话,mid值就是可行了,然后缩小区间往左找即可 因为保证有解,所以二分出来的mid值就是答案了 que…
FESTUNG模型介绍-1.对流方程求解 1. 控制方程 对流问题中,控制方程表达式为 \[\partial_t C + \partial_x (u^1 C) + \partial_y (u^2 C) = 0, \quad \mathrm{in} \; \Omega \] 其中边界处包含 Dirichlet 和 Neumann 边界条件,分别为 \[\begin{array}{cl} C = C_D & \mathrm{on} \; \partial \Omega_D, \\ - \nabla…
传送门 J-Counting Triangles_2021牛客暑期多校训练营3 (nowcoder.com) 题目 Goodeat finds an undirected complete graph with n vertices. Each edge of the graph is painted black or white. He wants you to help him find the number of triangles (a, b, c) (a < b < c), such…
题目链接 Problem Description zk has n numbers a1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk generates a new number (ai+aj). These new numbers could make up a new sequence b1,b2,...,bn(n−1)/2. LsF wants to make some trouble. While zk is sleeping, Ls…
题目链接 Problem Description The Death Star, known officially as the DS-1 Orbital Battle Station, also known as the Death Star I, the First Death Star, Project Stardust internally, and simply the Ultimate Weapon in early development stages, was a moon-si…
题目链接 Problem Description Galen Marek, codenamed Starkiller, was a male Human apprentice of the Sith Lord Darth Vader. A powerful Force-user who lived during the era of the Galactic Empire, Marek originated from the Wookiee home planet of Kashyyyk as…
题目链接 Problem Description In ACM/ICPC contest, the ''Dirt Ratio'' of a team is calculated in the following way. First let's ignore all the problems the team didn't pass, assume the team passed X problems during the contest, and submitted Y times for t…
题目链接 Problem Description Function Fx,ysatisfies: For given integers N and M,calculate Fm,1 modulo 1e9+7. Input There is one integer T in the first line. The next T lines,each line includes two integers N and M . 1<=T<=10000,1<=N,M<2^63. Output…
题目链接 Problem Description You are given an array A , and Zhu wants to know there are how many different array B satisfy the following conditions? 1≤Bi≤Ai For each pair( l , r ) (1≤l≤r≤n) , gcd(bl,bl+1...br)≥2 Input The first line is an integer T(1≤T≤1…
题目链接 Problem Description There is a youngster known for amateur propositions concerning several mathematical hard problems. Nowadays, he is preparing a thought-provoking problem on a specific type of supercomputer which has ability to support calcula…
题意:有一个n * n的网格,每个网格中间有一颗树,你知道每棵树的高,你可以选择一个矩形区域把里面的树都围起来,但是矩形区域里面任意两棵树的高度差的绝对值不超过m,问这个矩形的最大面积是多少? 思路:前两天的牛客多校有一个最大子矩形问题,当时用的扫描线 + 单调栈过的,结果场上想了半天灭结果QAQ.这个题有限制条件就不好那么做.注意到题目中的信息,可以用O(n ^ 3)的算法做,如果我们枚举矩阵的左上角和右下角是O(n ^ 4),而且没什么优化手段,不行.但是我们转化一下思路,我们枚举矩形的上边…
点击打开链接 我就不说官方题解有多坑了 V图那么高端的玩意儿 被精度坑粗翔了 AC前 AC后 简直不敢相信 只能怪自己没注意题目For the distance d1 and d2, if fabs(d1-d2)<1e-7, we think d1 == d2 有空再补充V图的做法吧..本人也是第一次接触V图 //大白p263 #include <cmath> #include <cstdio> #include <cstring> #include <se…
题目链接 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any other couples. Suddenly, LSH, Boss of FFF Group caught both of them, and locked them into two separate cells of the jail randomly. But as the saying goes:…
题目链接 Problem Description Giving two strings and you should judge if they are matched. The first string contains lowercase letters and uppercase letters. The second string contains lowercase letters, uppercase letters, and special symbols: "." an…
题目链接 Problem Description The Eternal Fleet was built many centuries ago before the time of Valkorion by an unknown race on the planet of Iokath. The fate of the Fleet's builders is unknown but their legacy would live on. Its first known action was in…
题目链接 Problem Description Kyber crystals, also called the living crystal or simply the kyber, and known as kaiburr crystals in ancient times, were rare, Force-attuned crystals that grew in nature and were found on scattered planets across the galaxy.…
题目链接 Problem Description There are n nonnegative integers a1-n which are less than p. HazelFan wants to know how many pairs i,j(1≤i<j≤n) are there, satisfying 1ai+aj≡1ai+1aj when we calculate module p, which means the inverse element of their sum equ…
题目链接 Problem Description HazelFan wants to build a rooted tree. The tree has n nodes labeled 0 to n−1, and the father of the node labeled i is the node labeled ⌊i−1k⌋. HazelFan wonders the size of every subtree, and you just need to tell him the XOR…
题目链接 Problem Description There is a nonnegative integer sequence a1...n of length n. HazelFan wants to do a type of transformation called prefix-XOR, which means a1...n changes into b1...n, where bi equals to the XOR value of a1,...,ai. He will repea…
题目链接 Problem Description There are n points on the plane, and the ith points has a value vali, and its coordinate is (xi,yi). It is guaranteed that no two points have the same coordinate, and no two points makes the line which passes them also passes…
题目链接 Problem Description Bob has a dictionary with N words in it. Now there is a list of words in which the middle part of the word has continuous letters disappeared. The middle part does not include the first and last character. We only know the pr…
题目链接 Problem Description The center coordinate of the circle C is O, the coordinate of O is (0,0) , and the radius is r. P and Q are two points not outside the circle, and PO = QO. You need to find a point D on the circle, which makes PD+QD minimum.…
题目链接 Problem Description Alice and Bob are playing a game called 'Gameia ? Gameia !'. The game goes like this : There is a tree with all node unpainted initial. Because Bob is the VIP player, so Bob has K chances to make a small change on the tree an…