(最新更新時間2018.11.2)
#include using namespace std;
//該int 型別只能 ++i,不能i++
//不支援負數運算
struct int//初始化負數為非負數,數字為0
void re ()//翻轉
void add (int k)//就是 a*10+k ,用於除法
int & operator = (int x)
int operator = (long long x)
bool operator == (int x)
bool operator < (const int x)
bool operator > (int x)
bool operator > (long long x)
inline bool operator >= (int x)
int operator * (long long x)
return *this*y;
} int operator + (int x)
while (y.num[0]>1&&!y.num[y.num[0]]) --y.num[0];
return y;
} int operator + (long long x)
return (y+*this);
} //下面同樣的
int operator += (int x)
int operator += (long long x)
int operator ++ ()
int operator *= (int x)
int operator *= (long long x)
int operator - (int x)
} while (y.num[0]>1&&!y.num[y.num[0]]) y.num[0]--;
return y;
} int operator -= (int x)
int operator / (int x)
tans.num[0]=num[0];
while (tans.num&&!tans.num[tans.num[0]]) --tans.num[0];
return tans;
} int operator / (long long x)
return tans;
} int operator /= (int x)
int operator /= (long long x)
int operator % (int x)
return y;
} int operator % (long long x)
int operator %= (int x)
friend ostream & operator <<(ostream & os,int x)
if (x.fs) os<<'-';//是負數就先輸出-號,雖然現在沒什麼用
for (int i=x.num[0];i;i--) os<>(istream & is,int &x)
return is;
}};
下面是壓位高精
#include #include #include #include using namespace std;
const int maxn = 1001;
const int power = 4;//壓多少位 達到10位把int 改為 long long
const int base = 10000;//10的幾次方
//輸入不是cin而是a.in()
//輸出不是cout而是a.out()
//不能++
//有這些運算子可用 + += - -= * *= / /= < <= > >=
struct int
void add (int k)
void re()
friend bool operator < (const int & x,const int & y)
friend bool operator >= (const int & x,const int & y)
} void out ()
int operator = (int x)
int operator = (long long x)
int operator + (int x)
while (!y.num[y.num[0]]) --y.num[0];
return y;
} int operator += (int x)
int operator - (int x)
while (y.num[0]&&!y.num[y.num[0]]) --y.num[0];
return y;
} int operator -= (int x)
while (num[0]&&!num[num[0]]) --num[0];
return *this;
} int operator * (int x)
while (y.num[0]&&!y.num[y.num[0]]) --y.num[0];
return y;
} int operator *= (int x)
int operator / (int x)
ans.num[0]=num[0];
while (ans.num[0]&&!ans.num[ans.num[0]]) --ans.num[0];
return ans;
} int operator /= (int x)
int operator % (int x)
while (y.num[0]&&!y.num[y.num[0]]) --y.num[0];
return y;
} int operator %= (int x)
};
C 大整數除法 大整數乘法
l1 046.整除光棍 這裡所謂的 光棍 並不是指單身汪啦 說的是全部由1組成的數字,比如1 11 111 1111等。傳說任何乙個光棍都能被乙個不以5結尾的奇數整除。比如,111111就可以被13整除。現在,你的程式要讀入乙個整數x,這個整數一定是奇數並且不以5結尾。然後,經過計算,輸出兩個數字 ...
大整數相加和大整數相乘
大整數運算是我們經常會碰到的演算法面試題之一。大整數運算往往會導致整形溢位而不能在ide直接通過四則運算執行。下面是python3寫的大整數相乘和大整數相加函式。原理都較為相似,模擬手寫演算的場景從後往前計算並且考慮進製。def multy n1,n2 n1 str n1 1 n2 str n2 1...
大整數加法
include include include include define debug void plus char char char int is valid char void reverse char int main int argc,char argv up loop 0 strcpy...