退役选手ZlycerQan的强大的的高精度
#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[]) {
;
}
退役选手ZlycerQan的强大的的高精度的更多相关文章
- NOI Online能力测试游记:退役选手的自娱自乐
2020年2月17日早上8点,CCF发布了关于举办NOI Online能力测试的通知. 为给选手提供一个锻炼的机会,CCF拟举办一场NOI Online能力测试.测试分为入门组和提高组,每组限额报名3 ...
- ACM-ICPC退役选手的发言——满满的正能量(短视频)
这是我在北京林业大学ACM-ICPC竞赛说明会上发言的录像 希望能激励大家在奋斗的道路上披荆斩棘,勇往直前!
- 【NOIP2018】【RP++!】【神大退役记+一丢丢回忆录】
emmm初赛都完了啊,还有20多天的样子退役选手又要++++++了 所以在这里先预祝各路dalao取得好成绩!! 手动艾特亲友$@Abyssful@阿澈说他也想好好学习@Ed\_Sheeran@歪瓜是 ...
- NOI2019退役记 upd:2019.12.1
(我把原来写的东西全部删掉了) AFO. 我退役了,\(\mbox{yyb}\)退役了. 至少,在接下来的日子里,我得投身到文化课,度过快乐的高三生活了. 这两年的\(OI\)生涯给了我很多,让我学会 ...
- 退役——halfrot's life in OI
这是一个没有人看的博客里丢了两年的坑,还有很多事应该做,但是我很懒,所以今天把它填了. 前记:和很多人的竞赛生涯一样,一开始我也是奋不顾身,奔月而去,然而身处弱校,没有人引导方向,再加上自己很蒻的主要 ...
- 退役记——CCC2020&CCO2020
我叫吴佳诚,一个曾在福建师大附中就读的oier,2019年7月份我来到多伦多就读于Langstaff Secondary School 我的常用id有:Johnson_Wu,温词 竞赛经历: 2018 ...
- lnoi2019游记
好诡异的省选...... day0: 莫名其妙的订了下午从sy到dl的火车,得五点多才能到,所以.......是不需要试机的吗...... 好吧... 看着停课的jflr们,感觉他们好强啊,像我这种酱 ...
- CTSC2016&&APIO2016滚粗记&&酱油记&&游记<del>(持续更新)</del>
挖一波坑 #include <cstdio> using namespace std; int main(){ puts("转载请注明出处:http://www.cnblogs. ...
- SHOI2016游记&滚粗记&酱油记
Day0 学校刚期中考完,全科血崩,感觉这次真要考不到一本线了tat 晚上写了个可持久化trie的题,也懒得敲板子(上个礼拜都敲过了),就碎叫了 Day1 上午起床吃饭水群看球,吃完中饭就去考场了. ...
随机推荐
- git中文件的三种状态
用xcode的时候,左侧栏文件的邮右边时不时会看到M,A这一类的字母.当然,这些以后再写上.先说一下git里文件的三种状态 已提交(committed) 已经提交的本地仓库(repository), ...
- 模板 - 字符串 - Manacher
求最长回文子串. #include<bits/stdc++.h> using namespace std; #define ll long long ; ]; ]; int Manache ...
- Codeforces Round #408 (Div. 2) D. Police Stations(最小生成树+构造)
传送门 题意 n个点有n-1条边相连,其中有k个特殊点,要求: 删去尽可能多的边使得剩余的点距特殊点的距离不超过d 输出删去的边数和index 分析 比赛的时候想不清楚,看了别人的题解 一道将1个联通 ...
- IT兄弟连 Java Web教程 经典面试题2
1.Servlet的工作流程? Servlet是运行在Servlet容器中的,由Servlet容器来负责Servlet实例的查找.创建以及整个生命周期的管理,Servlet整个生命周期可以分为四个阶段 ...
- 题解报告:NYOJ #737 石子合并(一)(区间dp)
描述 有N堆石子排成一排,每堆石子有一定的数量.现要将N堆石子并成为一堆.合并的过程只能每次将相邻的两堆石子堆成一堆,每次合并花费的代价为这两堆石子的和,经过N-1次合并后成为一堆.求出总的代价最小值 ...
- PopupWindow(2)简单示例-自定义弹出菜单
本示例,用 popupWindow 自定义弹出菜单 public class CustomActionProvider extends ActionProvider implements OnMenu ...
- [未读]JavaScript高效图形编程
去年买来就一直搁置,因为是js游戏相关,暂时还用不到.
- Json和序列化总结
一.序言 遇到问题,就经常逛园,不知你是否曾有,曾经遇到的问题,或者在园子里看到问题的方案,过一段时间,有可能还会摔跤,哈哈...大神请勿喷,小弟记忆不太好,还过来找资料,如果自己写把问题或某个知识点 ...
- 启动hadoop时报root@localhost's password: localhost: Permission denied, please try again.错误。
背景:在装完hadoop及jdk之后,在执行start-all.sh的时候出现root@localhost's password:localhost:permission denied,please ...
- AJPFX总结private关键字
private关键字 什么是private关键字? 它是一个修饰符,代表私有的意思,它可以修饰成员变量和成员方法 private关键字的特点? ...