#integers

poj 2891 Strange Way to Express Integers(中国剩余定理)

http://poj.org/problem?id=2891题意:求解一个数x使得x%8=7,x%11=9;   若x存在,输出最小整数解。否则输出-1;ps:思路:这不是简单的中国剩余定理问题,由于输入的ai不一定两两互质,而中国剩余定理的条件是除数两两互质。   这是一般的模线性方程组,对于    Xmodm1=r...
代码星球 代码星球·2021-02-13

poj 3466 A Simple Problem with Integers

题目链接:http://poj.org/problem?id=3468 http://poj.org/problem?id=3468 http://poj.org/problem?id=3468思路:这是一个区间改动区间查询的题,因为题目中的给的数据比較大,那么用单个改动和查询肯定不行,所以。。。。...

LeetCode: 29. Divide Two Integers (Medium)

https://leetcode.com/problems/divide-two-integers/description/给出被除数dividend和除数divisor,求出二者相除的商,余数忽略不计。注意:不能使用乘法、除法和取余运算陷阱一:MIN_VALUE/-1会溢出。因为Integer.MIN_VALUE=-...

HDU 1796 How many integers can you find

TimeLimit:12000/5000MS(Java/Others)    MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):5605    AcceptedSubmissio...

Codeforces Round #609 (Div. 2)E--K Integers(贪心+二分+树状数组+逆序对)

KIntegers参考博客:https://blog.csdn.net/Q755100802/article/details/103664555 【题意】给定一个1到n的排列,可以交换相邻的两个元素。现在定义一个函数f(x),表示在原排列中,通过交换操作,形成一个1,2,3....x的排列的子串,需要的最小操...

leetcode 67. Add Binary 、2. Add Two Numbers 、445. Add Two Numbers II 、43. Multiply Strings 字符串相乘 、29. Divide Two Integers

对于几进制,其实主要就是对进制取余和整除,取余的结果就是当前位的,整除的结果就是进位的。 67.AddBinaryhttps://www.cnblogs.com/grandyang/p/4084971.html从两个string的末尾开始转int型相加,注意carry的计算。如果某一个数少于另一个数,就用0代...

leetcode 29-> Divide Two Integers without using multiplication, division and mod operator

 classSolution(object):defdivide(self,dividend,divisor):""":typedividend:int:typedivisor:int:rtype:int"""ispositive=Trueifdividend>0anddivisor<0:ispo...

POJ2891 Strange Way to Express Integers 扩展欧几里德 中国剩余定理

  给出k个同余方程组:xmodai=ri。求x的最小正值。如果不存在这样的x,那么输出-1.不满足所有的ai互质。  UPD(2018-08-07):  本题做法为扩展中国剩余定理。  我写了一篇证明:链接:https://www.cnblogs.com/zhouzhendong/p/exCRT.html  代码就不...