CF20B Equation 题解】的更多相关文章

Content 解方程 \(ax^2+bx+c=0\). 数据范围:\(-10^5\leqslant a,b,c\leqslant 10^5\). Solution 很明显上求根公式. 先来给大家推推求根公式吧. \[\begin{aligned}ax^2+bx+c&=0\color{Red}~(a\neq0)\\ax^2+bx&=-c&(1)\\x^2+\dfrac bax&=-\dfrac ca&(2)\\x^2+\dfrac bax+\left(\dfrac{…
题目链接: 咕 闲扯: 终于在集训中敲出正解(虽然与正解不完全相同),开心QAQ 首先比较巧,这题是\(Ebola\)出的一场模拟赛的一道题的树上强化版,当时还口胡出了那题的题解 然而考场上只得了86最后一个substask被卡了,一开始以为毒瘤出题人卡常(虽然真卡了)卡线段树,题目时限1.5s,评测机上两个点擦线1500ms左右,剩下两个点不知道.然后本地测一下都是1900+ms!机子性能已经这样了吗....结果把快读换成\(fread\),TM过了!最慢的1200+ms!!!这......无…
Problem Description Now,given the equation 8x^4 + 7x^3 + 2x^2 + 3x + 6 == Y,can you find its solution between 0 and 100; Now please try your lucky. Input The first line of the input contains an integer T(1<=T<=100) which means the number of test cas…
题意: 求AX^2+BX+C=0的根 思路: 考虑到A,B,C所有可能的情况 代码: double a,b,c; int main(){ cin>>a>>b>>c; if(a==0){ if(b==0){ if(c==0){ puts("-1"); ret 0; } else{ puts("0"); ret 0; } } else{ print("1\n%.10lf\n",(-c)/b); ret 0; } }…
A. Protect Sheep time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus dec…
There is an equation ax + by + c = 0. Given a,b,c,x1,x2,y1,y2 you must determine, how many integer roots of this equation are satisfy to the following conditions : x1<=x<=x2,   y1<=y<=y2. Integer root of this equation is a pair of integer numb…
B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following proble…
题面:https://www.cnblogs.com/Juve/articles/11619002.html merchant: 二分答案,贪心选前m大的 但是用sort复杂度不优,会T掉 我们只是找前m大的,至于前m大的如何排序我们并不关心 所以用nth_element()函数找出前m大的,然后贪心check #include<iostream> #include<cstdio> #include<cstring> #include<algorithm>…
题意: 传送门 已知\(0 <= x <= y < p, p = 1e9 + 7\)且有 \((x+y) = b\mod p\) \((x\times y)=c\mod p\) 求解任意一对\(x,y\),不存在输出\(-1\ -1\). 思路: 由两式变化可得\((y - x)^2 = (b^2 -4c + p) \% p \mod p\),那么可以应用二次剩余定理解得\(y - x\)的值,我们可以知道\((x+y) = b\)或者\((x+y) = b + p\),那么直接求解即可…
传送门 考场上打了两个小时树剖,结果还是没搞出来 发现对于两个确定的点,它们一定可以列出一个方程来 其中系数的大小和正负只与这两点间距离的奇偶性有关 所以可以加一堆分情况讨论然后树剖 至于正解: 考虑两点之间的关系很麻烦,可以固定一个基准点,把它们都用 \(x_1\) 表示出来 当需要极其麻烦地考虑两点之间的关系时,考虑固定一个基准点分别表示它们 发现这样的话对一个点的修改等价于把它的子树整体加上一个数 所以可以建立dfs序,直接树状数组维护,同样根据奇偶性判无解 Code: #include…