Warning: mysqli_query(): (HY000/1021): Disk full (/tmp/#sql_51b_2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device") in /opt/lampp/htdocs/wordpress/wp-includes/wp-db.php on line 2033

# 算法2()-其他

## 算法2()

4.二分算法（浮点数)bool check(double x)…..//x满足某种性质void bsearch_3(double l,double r){const eps=1e-6;//控制精度while(i-j<eps){int mid=(l+r)/2;if(check(mid))l=mid;r=mid;}5.高精度加法vector<int>add(vector<int>&A,vector<int>&B){int t=0;vector<int>c;for(int i=0;i<A.size()||i<B.size();i++){if(i<A.size()) t+=A[i];if(i<B.size()) t+=B[i];c.push_back(t%10);t/=10;}if(t)c.push_back(1);return c;}6.高精度减法vector<int>cmp(vector<int>&A,vector<int>&B)//比较A和B大小{if(A.size()!=B.size())return A.size()>.size();else{for(int i=0;i<a.size();i++)if(A[i]!=B[i])return A[i]>B[i];else return true;}}vector<int>sub(vector<int>&A,vector<int>&B){vector<int>c;for(int i=0,t=0;i<A.size();i++)//默认A>B{t=A[i]-t;if(i<B.size())t-=B[i];c.push_back((t+10)%10);t/=10;}if(c.size()>1&&c.back()==0)c.pop_back();return c;}7.高精度乘法vector<int>mcl(vector<int>&A,int b){vector<int>c;int t=0;for(int i=0;i<A.size()||t;i++){if(i<A.size())t=A[i]*b;c.push_back(t%10);t/=10;}if(c.size()>1&&c.back()==0)c.pop_back();return c;}8.高精度除法vector<int>mcl(vector<int>&A,int b,int &r){r=0;for(int i=A.size()-1;i>=0;i–){r=10*r+A[i];c.push_back(r/b);c%=b;}reserve(c.begin(),c.end());if(c.size()>1&&c.back()==0)c.pop_back();return c;}

————————

4.二分算法（浮点数)bool check(double x)…..//x满足某种性质void bsearch_3(double l,double r){const eps=1e-6;//控制精度while(i-j<eps){int mid=(l+r)/2;if(check(mid))l=mid;r=mid;}5.高精度加法vector<int>add(vector<int>&A,vector<int>&B){int t=0;vector<int>c;for(int i=0;i<A.size()||i<B.size();i++){if(i<A.size()) t+=A[i];if(i<B.size()) t+=B[i];c.push_back(t%10);t/=10;}if(t)c.push_back(1);return c;}6.高精度减法vector<int>cmp(vector<int>&A,vector<int>&B)//比较A和B大小{if(A.size()!=B.size())return A.size()>.size();else{for(int i=0;i<a.size();i++)if(A[i]!=B[i])return A[i]>B[i];else return true;}}vector<int>sub(vector<int>&A,vector<int>&B){vector<int>c;for(int i=0,t=0;i<A.size();i++)//默认A>B{t=A[i]-t;if(i<B.size())t-=B[i];c.push_back((t+10)%10);t/=10;}if(c.size()>1&&c.back()==0)c.pop_back();return c;}7.高精度乘法vector<int>mcl(vector<int>&A,int b){vector<int>c;int t=0;for(int i=0;i<A.size()||t;i++){if(i<A.size())t=A[i]*b;c.push_back(t%10);t/=10;}if(c.size()>1&&c.back()==0)c.pop_back();return c;}8.高精度除法vector<int>mcl(vector<int>&A,int b,int &r){r=0;for(int i=A.size()-1;i>=0;i–){r=10*r+A[i];c.push_back(r/b);c%=b;}reserve(c.begin(),c.end());if(c.size()>1&&c.back()==0)c.pop_back();return c;}