#include <cstdio>
#include <iostream>
#include <vector>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <cstring> const int Big_B = ;
const int Big_L = ;
inline int intcmp_ (int a, int b) {
if (a > b) return ;
return a < b ? - : ;
}
struct Int {
#define rg register
inline int max (int a, int b) {
return a > b ? a : b;
}
inline int min (int a, int b) {
return a < b ? a : b;
}
std :: vector <int> c;
Int () {} typedef long long LL;
Int (int x) {
for (; x > ; c.push_back (x % Big_B), x /= Big_B);
}
Int (LL x) {
for (; x > ; c.push_back (x % Big_B), x /= Big_B);
}
inline void CrZ () {
for (; !c.empty () && c.back () == ; c.pop_back ());
}
inline Int &operator += (const Int &rhs) {
c.resize (max (c.size (), rhs.c.size ()));
rg int i, t = , S;
for (i = , S = rhs.c.size (); i < S; ++ i)
c[i] += rhs.c[i] + t, t = c[i] >= Big_B, c[i] -= Big_B & (-t);
for (i = rhs.c.size (), S = c.size (); t && i < S; ++ i)
c[i] += t, t = c[i] >= Big_B, c[i] -= Big_B & (-t);
if (t) c.push_back (t);
return *this;
}
inline Int &operator -= (const Int &rhs) {
c.resize (max (c.size (), rhs.c.size ()));
rg int i, t = , S;
for (i = , S = rhs.c.size (); i < S; ++ i)
c[i] -= rhs.c[i] + t, t = c[i] < , c[i] += Big_B & (-t);
for (i = rhs.c.size (), S = c.size (); t && i < S; ++ i)
c[i] -= t, t = c[i] < , c[i] += Big_B & (-t);
CrZ ();
return *this;
}
inline Int &operator *= (const Int &rhs) {
rg int na = c.size (), i, j, S, ai;
c.resize (na + rhs.c.size ());
LL t;
for (i = na - ; i >= ; -- i) {
ai = c[i], t = , c[i] = ;
for (j = , S = rhs.c.size (); j < S; ++ j) {
t += c[i + j] + (LL) ai * rhs.c[j];
c[i + j] = t % Big_B, t /= Big_B;
}
for (j = rhs.c.size (), S = c.size (); t != && i + j < S; ++ j)
t += c[i + j], c[i + j] = t % Big_B, t /= Big_B;
assert (t == );
}
CrZ ();
return *this;
}
inline Int &operator /= (const Int &rhs) {
return *this = div (rhs);
}
inline Int &operator %= (const Int &rhs) {
return div (rhs), *this;
}
inline Int &shlb (int l = ) {
if (c.empty ()) return *this;
c.resize (c.size () + l);
rg int i;
for (i = c.size () - ; i >= l; -- i) c[i] = c[i - l];
for (i = ; i < l; ++ i) c[i] = ;
return *this;
}
inline Int &shrb (int l = ) {
for (rg int i = ; i < c.size () - l; ++ i) c[i] = c[i + l];
c.resize (max (c.size () - l, ));
return *this;
}
inline int Comp (const Int &rhs) const {
if (c.size () != rhs.c.size ()) return intcmp_ (c.size (), rhs.c.size ());
for (rg int i = c.size () - ; i >= ; -- i)
if (c[i] != rhs.c[i]) return intcmp_ (c[i], rhs.c[i]);
return ;
}
inline Int div (const Int &rhs) {
assert (!rhs.c.empty ());
Int q, r;
rg int i;
if (rhs > *this) return ;
q.c.resize (c.size () - rhs.c.size () + );
rg int _l, _r, mid;
for (i = c.size () - ; i > c.size () - rhs.c.size (); -- i) r.shlb (), r += c[i];
for (i = c.size () - rhs.c.size (); i >= ; -- i) {
r.shlb ();
r += c[i];
if (r.Comp (rhs) < ) q.c[i] = ;
else {
_l = , _r = Big_B;
for (; _l != _r; ) {
mid = _l + _r >> ;
if ((rhs * mid).Comp (r) <= ) _l = mid + ;
else _r = mid;
}
q.c[i] = _l - , r -= rhs * q.c[i];
}
}
q.CrZ (), *this = r;
return q;
}
friend inline Int operator + (const Int &lhs, const Int &rhs) {
Int res = lhs;
return res += rhs;
}
friend inline Int operator - (const Int &lhs, const Int &rhs) {
Int res = lhs;
return res -= rhs;
}
friend inline Int operator * (const Int &lhs, const Int &rhs) {
Int res = lhs;
return res *= rhs;
}
friend inline Int operator / (const Int &lhs, const Int &rhs) {
Int res = lhs;
return res.div (rhs);
}
friend inline Int operator % (const Int &lhs, const Int &rhs) {
Int res = lhs;
return res.div (rhs), res;
}
friend inline std :: ostream &operator << (std :: ostream &out, const Int &rhs) {
if (rhs.c.size () == ) out << "";
else {
out << rhs.c.back ();
for (rg int i = rhs.c.size () - ; i >= ; -- i)
out << std :: setfill ('') << std :: setw (Big_L) << rhs.c[i];
}
return out;
}
friend inline std :: istream &operator >> (std :: istream &in, Int &rhs) {
static char s[];
in >> s + ;
int Len = strlen (s + );
int v = ;
LL r = , p = ;
for (rg int i = Len; i >= ; -- i) {
++ v;
r = r + (s[i] - '') * p, p *= ;
if (v == Big_L) rhs.c.push_back (r), r = , v = , p = ;
}
if (v != ) rhs.c.push_back (r);
return in;
}
friend inline bool operator < (const Int &lhs, const Int &rhs) {
return lhs.Comp (rhs) < ;
}
friend inline bool operator <= (const Int &lhs, const Int &rhs) {
return lhs.Comp (rhs) <= ;
}
friend inline bool operator > (const Int &lhs, const Int &rhs) {
return lhs.Comp (rhs) > ;
}
friend inline bool operator >= (const Int &lhs, const Int &rhs) {
return lhs.Comp (rhs) >= ;
}
friend inline bool operator == (const Int &lhs, const Int &rhs) {
return lhs.Comp (rhs) == ;
}
friend inline bool operator != (const Int &lhs, const Int &rhs) {
return lhs.Comp (rhs) != ;
}
#undef rg
};
Int a;
int Main () {
return ;
}
int ZlycerQan = Main ();
int main (int argc, char *argv[]) {
;
}

最新文章

  1. Spark MLlib 之 Naive Bayes
  2. 解析C#开发过程常见的编程模式
  3. How to pronounce symbols on keyboard
  4. python学习心得第四章
  5. 拼图游戏(js,C#,java三种语言)
  6. doPost方法与doGet方法
  7. Visual Studio 如何恢复默认设置
  8. android 21 隐式意图启动系统预定义activity
  9. maven上传自定义jar到本地仓库
  10. [Cycle.js] Hyperscript as our alternative to template languages
  11. Jquery遍历数组之$.inArray()方法介绍
  12. OpenGL缓冲区
  13. JS自定义对象以及相关成绩系统完整案例演示
  14. scrapy_简介页面和详情页面
  15. python中的randint,引入模块
  16. Pycharm 设置上下左右快捷键
  17. HDU 1848 Fibonacci again and again【博弈SG】
  18. Vue中router两种传参方式
  19. win7卸载IE11
  20. JqGrid 隐藏水平滚动条完美解决方案

热门文章

  1. 一个表的两个字段具有相同的类型。如何仅用SQL语句交换这两列的数据?
  2. MFC类别概述
  3. BERT的几个可能的应用
  4. IT兄弟连 JavaWeb教程 请求转发案例
  5. 大型系统的Redis性能优化
  6. ubuntu 直接用软件的名字启动非apt安装的软件
  7. bzoj 4456 [Zjoi2016]旅行者
  8. 洛谷P3379lca,HDU2586,洛谷P1967货车运输,倍增lca,树上倍增
  9. Apache Kylin的核心概念
  10. aspx子集页面找父级页面元素