使用说明:

  1. 数据范围约为\(-2^{1024}\le N \le2^{1024}\),反映到十进制约为\(-10^{309}\le N \le10^{309}\),但不保证完全如此。
  2. 输入输出使用自带的输入及输出函数。由于其内部用scanfprintf来实现,所以请不要把它与ios::sync_with_stdio(false)同时使用。
  3. 由于内部采用高精度实现,所以复杂度不可忽略。具体复杂度会在下面列出。
  4. 特别地,自增及自减运算只能放在变量前面。如置于后面会报错。

    支持操作:
  5. 输入输出。使用.in().out()即可。
  6. 运算。支持+-*/%``++``--共七种运算,类比int使用即可。
  7. 赋值。直接使用=即可。
  8. 比较关系。支持>>=<<===!=共六种运算,类比int使用即可。

    头文件&宏定义:

    宏定义不喜可换。
#include<iostream>
#include<string.h>
using namespace std;
#define il inline
#define ri register int

正片:

因为本来就没想让别人读懂所以一点注释都没加。

struct __int1024
{
string zp;
il void out()
{
int h=0;
if(zp[h]=='-')
{
printf("%c",zp[h]);
h++;
}
while(zp[h]>='0'&&zp[h]<='9')
{
printf("%c",zp[h]);
h++;
}
return;
}
il void in()
{
char c=' ';
while(scanf("%c",&c)!=EOF)
{
if(c=='+'||c=='-')
{
break;
}
if(c>='0'&&c<='9')
{
break;
}
}
if(c=='-')
{
zp.push_back(c);
}
if(c>='0'&&c<='9')
{
zp.push_back(c);
}
while(scanf("%c",&c)!=EOF)
{
if(c=='+')
{
continue;
}
if(c=='-')
{
zp.push_back(c);
continue;
}
if(c>='0'&&c<='9')
{
zp.push_back(c);
continue;
}
break;
}
return;
}
il bool dayu(__int1024 x,__int1024 y)
{
if(x.zp[0]=='-'&&y.zp[0]=='-')
{
__int1024 m,n;
int u=x.zp.size(),v=x.zp.size();
m.zp=x.zp.substr(1,u-1);
n.zp=y.zp.substr(1,v-1);
return dayu(n,m);
}
if(x.zp[0]=='-')
{
return false;
}
if(y.zp[0]=='-')
{
return true;
}
if(x.zp.size()>y.zp.size())
{
return true;
}
if(x.zp.size()<y.zp.size())
{
return false;
}
for(ri i=0;i<x.zp.size();i++)
{
if(x.zp[i]>y.zp[i])
{
return true;
}
if(x.zp[i]<y.zp[i])
{
return false;
}
}
return false;
}
il bool xiaoyu(__int1024 x,__int1024 y)
{
if(x.zp[0]=='-'&&y.zp[0]=='-')
{
__int1024 m,n;
int u=x.zp.size(),v=x.zp.size();
m.zp=x.zp.substr(1,u-1);
n.zp=y.zp.substr(1,v-1);
return xiaoyu(n,m);
}
if(x.zp[0]=='-')
{
return true;
}
if(y.zp[0]=='-')
{
return false;
}
if(x.zp.size()<y.zp.size())
{
return true;
}
if(x.zp.size()>y.zp.size())
{
return false;
}
for(ri i=0;i<x.zp.size();i++)
{
if(x.zp[i]<y.zp[i])
{
return true;
}
if(x.zp[i]>y.zp[i])
{
return false;
}
}
return false;
}
il bool dengyu(__int1024 x,__int1024 y)
{
if(x.zp.size()!=y.zp.size())
{
return false;
}
for(ri i=0;i<x.zp.size();i++)
{
if(x.zp[i]!=y.zp[i])
{
return false;
}
}
return true;
}
il __int1024 jia(__int1024 x,__int1024 y)
{
string rn;
__int1024 qm;
int u=x.zp.size(),v=y.zp.size(),w;
if(x.zp[0]=='-'&&y.zp[0]=='-')
{
__int1024 m,n,z;
m.zp=x.zp.substr(1,u-1);
n.zp=y.zp.substr(1,v-1);
z=jia(m,n);
if(z.zp[0]=='-')
{
rn=z.zp.substr(1,z.zp.size()-1);
}
else
{
rn.resize(1,'-');
rn+=z.zp;
}
qm.zp=rn;
return qm;
}
if(x.zp[0]=='-')
{
__int1024 z;
z.zp=x.zp.substr(1,u-1);
return jian(y,z);
}
if(y.zp[0]=='-')
{
__int1024 z;
z.zp=y.zp.substr(1,v-1);
return jian(x,z);
}
int o[310],p[310],q[310];
memset(o,0,sizeof(o));
memset(p,0,sizeof(p));
memset(q,0,sizeof(q));
for(ri i=0,j=u;j>0;i++,j--)
{
p[j]=x.zp[i]-'0';
}
for(ri i=0,j=v;j>0;i++,j--)
{
q[j]=y.zp[i]-'0';
}
w=max(u,v);
for(ri i=1;i<=w+1;i++)
{
int j=p[i]+q[i];
o[i]+=j;
o[i+1]+=o[i]/10;
o[i]%=10;
}
if(o[w+1]!=0)
{
w++;
}
rn.resize(w,'0');
for(ri i=0,j=w;j>0;i++,j--)
{
rn[i]+=o[j];
}
qm.zp=rn;
return qm;
}
il __int1024 jian(__int1024 x,__int1024 y)
{
__int1024 qm;
string rn;
int u=x.zp.size(),v=y.zp.size(),w;
if(x.zp[0]=='-'&&y.zp[0]=='-')
{
__int1024 m,n,z;
m.zp=x.zp.substr(1,u-1);
n.zp=y.zp.substr(1,v-1);
z=jian(m,n);
w=z.zp.size();
if(z.zp[0]=='-')
{
rn=z.zp.substr(1,w-1);
}
else
{
rn.resize(1,'-');
rn+=z.zp;
}
qm.zp=rn;
return qm;
}
if(y.zp[0]=='-')
{
__int1024 z;
z.zp=y.zp.substr(1,v-1);
return jia(x,z);
}
if(x.zp[0]=='-')
{
__int1024 z,t;
z.zp=x.zp.substr(1,u-1);
t=jia(z,y);
qm.zp.resize(1,'-');
qm.zp+=t.zp;
return qm;
}
if(dayu(x,y)==false&&dengyu(x,y)==false)
{
__int1024 m,n,z;
m.zp=x.zp;
n.zp=y.zp;
z=jian(n,m);
w=z.zp.size();
if(z.zp[0]=='-')
{
rn=z.zp.substr(1,w-1);
}
else
{
rn.resize(1,'-');
rn+=z.zp;
}
qm.zp=rn;
return qm;
}
int o[310],p[310],q[310];
memset(o,0,sizeof(o));
memset(p,0,sizeof(p));
memset(q,0,sizeof(q));
for(ri i=0,j=u;j>0;i++,j--)
{
p[j]=x.zp[i]-'0';
}
for(ri i=0,j=v;j>0;i++,j--)
{
q[j]=y.zp[i]-'0';
}
for(ri i=1;i<=u;i++)
{
int j=p[i]-q[i];
o[i]+=j;
o[i+1]+=o[i]/10;
o[i]%=10;
if(o[i]<0)
{
o[i]+=10;
o[i+1]-=1;
}
}
while(o[u]==0&&u!=1)
{
u--;
}
rn.resize(u,'0');
for(ri i=0,j=u;j>0;i++,j--)
{
rn[i]+=o[j];
}
qm.zp=rn;
return qm;
}
il __int1024 cheng(__int1024 x,__int1024 y)
{
string rn;
__int1024 qm;
int u=x.zp.size(),v=y.zp.size(),w;
if(x.zp[0]=='-'&&y.zp[0]=='-')
{
__int1024 m,n;
m.zp=x.zp.substr(1,u-1);
n.zp=y.zp.substr(1,v-1);
return cheng(m,n);
}
if(x.zp[0]=='-'||y.zp[0]=='-')
{
__int1024 m,n,z;
m.zp=x.zp.substr(1,u-1);
n.zp=y.zp.substr(1,v-1);
z=cheng(m,n);
if(z.zp[0]=='-')
{
rn=z.zp.substr(1,z.zp.size()-1);
}
else
{
rn.resize(1,'-');
rn+=z.zp;
}
qm.zp=rn;
return qm;
}
int o[310],p[310],q[310];
memset(o,0,sizeof(o));
memset(p,0,sizeof(p));
memset(q,0,sizeof(q));
for(ri i=0,j=u;j>0;i++,j--)
{
p[j]=x.zp[i]-'0';
}
for(ri i=0,j=v;j>0;i++,j--)
{
q[j]=y.zp[i]-'0';
}
w=u+v;
for(ri i=1;i<=u;i++)
{
for(ri j=1;j<=v;j++)
{
int k=p[i]*q[j];
o[i+j-1]+=k;
o[i+j]+=o[i+j-1]/10;
o[i+j-1]%=10;
}
}
while(o[w]==0&&w!=1)
{
w--;
}
rn.resize(w,'0');
for(ri i=0,j=w;j>0;i++,j--)
{
rn[i]+=o[j];
}
qm.zp=rn;
return qm;
}
il __int1024 chu(__int1024 x,__int1024 y)
{
string rn;
__int1024 qm;
int u=x.zp.size(),v=y.zp.size();
if(x.zp[0]=='-'&&y.zp[0]=='-')
{
__int1024 m,n;
m.zp=x.zp.substr(1,u-1);
n.zp=y.zp.substr(1,v-1);
return chu(m,n);
}
if(x.zp[0]=='-')
{
__int1024 m,z;
m.zp=x.zp.substr(1,u-1);
z=chu(m,y);
if(z.zp[0]=='-')
{
rn=z.zp.substr(1,z.zp.size()-1);
}
else
{
rn.resize(1,'-');
rn+=z.zp;
}
qm.zp=rn;
return qm;
}
if(y.zp[0]=='-')
{
__int1024 n,z;
n.zp=y.zp.substr(1,v-1);
z=chu(x,n);
if(z.zp[0]=='-')
{
rn=z.zp.substr(1,z.zp.size()-1);
}
else
{
rn.resize(1,'-');
rn+=z.zp;
}
qm.zp=rn;
return qm;
}
if(dayu(x,y)==false&&dengyu(x,y)==false)
{
qm.zp="0";
return qm;
}
int o[310],p[310],q[310];
memset(o,0,sizeof(o));
memset(p,0,sizeof(p));
memset(q,0,sizeof(q));
for(ri i=0;i<u;i++)
{
p[i+1]=x.zp[i]-'0';
}
for(ri i=0;i<u;i++)
{
q[i+1]=y.zp[i]-'0';
}
int rt=1;
for(ri i=1;i<=u;i++)
{
if(rt>i)
{
o[i]=0;
continue;
}
string al=x.zp.substr(0,i-rt+1);
__int1024 z;
z.zp=al;
if(dayu(y,z)==true)
{
o[i]=0;
continue;
}
int m=1,n=9;
while(n-m>1)
{
char l=((m+n)>>1)+'0';
__int1024 wn;
wn.zp.push_back(l);
if(dayu(cheng(y,wn),z)==true)
{
n=l-'0'-1;
}
else
{
m=l-'0';
}
}
char l=n+'0';
__int1024 wn,xo;
wn.zp.push_back(l);
if(dayu(cheng(y,wn),z)==false)
{
o[i]=n;
wn.zp[0]=n+'0';
xo=cheng(wn,y);
for(ri j=i+1;j<=u;j++)
{
xo.zp.push_back('0');
}
int sk=x.zp.size();
x=jian(x,xo);
rt+=sk-x.zp.size();
}
else
{
o[i]=m;
wn.zp[0]=m+'0';
xo=cheng(wn,y);
for(ri j=i+1;j<=u;j++)
{
xo.zp.push_back('0');
}
int sk=x.zp.size();
x=jian(x,xo);
rt+=sk-x.zp.size();
}
}
int w=1;
while(o[w]==0&&w!=u)
{
w++;
}
rn.resize(u-w+1,'0');
for(ri i=0,j=w;j<=u;i++,j++)
{
rn[i]+=o[j];
}
qm.zp=rn;
return qm;
}
__int1024 zjia(__int1024 x)
{
string rn;
if(x.zp[0]=='-')
{
__int1024 y,z;
y.zp=x.zp.substr(1,x.zp.size());
z=zjian(y);
if(z.zp[0]!='0')
{
rn=z.zp;
z.zp='-';
z.zp+=rn;
}
return z;
}
int h=x.zp.size()-1;
while(x.zp[h]=='9'&&h>=0)
{
x.zp[h]='0';
h--;
}
if(h<0)
{
rn=x.zp;
x.zp='1';
x.zp+=rn;
}
else
{
x.zp[h]+=1;
}
return x;
}
__int1024 zjian(__int1024 x)
{
string rn;
if(x.zp[0]=='0')
{
x.zp="-1";
return x;
}
if(x.zp[0]=='-')
{
__int1024 y,z;
y.zp=x.zp.substr(1,x.zp.size());
z=zjia(y);
if(z.zp[0]!='0')
{
rn=z.zp;
z.zp='-';
z.zp+=rn;
}
return z;
}
int h=x.zp.size()-1;
while(x.zp[h]=='0'&&h>=0)
{
x.zp[h]='9';
h--;
}
if(h<0)
{
rn=x.zp.substr(1,x.zp.size()-1);
x.zp+=rn;
}
else
{
x.zp[h]-=1;
}
return x;
}
__int1024 operator +(const __int1024 &A)
{
return jia(*this,A);
}
__int1024 operator -(const __int1024 &A)
{
return jian(*this,A);
}
__int1024 operator*(const __int1024 &A)
{
return cheng(*this,A);
}
__int1024 operator/(const __int1024 &A)
{
return chu(*this,A);
}
__int1024 operator%(const __int1024 &A)
{
return jian(*this,cheng(A,chu(*this,A)));
}
void operator++()
{
*this=zjia(*this);
}
void operator--()
{
*this=zjian(*this);
}
void operator =(const __int1024 &A)
{
zp=A.zp;
return;
}
bool operator >(const __int1024 &A)
{
return dayu(*this,A);
}
bool operator <(const __int1024 &A)
{
return xiaoyu(*this,A);
}
bool operator ==(const __int1024 &A)
{
return dengyu(*this,A);
}
bool operator >=(const __int1024 &A)
{
return (dayu(*this,A)||dengyu(*this,A));
}
bool operator <=(const __int1024 &A)
{
return (xiaoyu(*this,A)||dengyu(*this,A));
}
bool operator !=(const __int1024 &A)
{
return (dengyu(*this,A)==true)?false:true;
}
};

后记:

想学高精建议打P1932

__int65536正加紧制作中!

随机推荐

  1. [BlockChain] 三方互惠是公共区块链得以发展的基石, dApp数字通证的运转需要可持续性玩法

    ------------------------------- 公链 旷工    开发者/用户 ------------------------------- -------------------- ...

  2. dotnet SemanticKernel 入门 开篇

    本文将开坑告诉大家什么是 SemanticKernel 以及如何使用框架 众所周知 GPT 是一个大语言模型,能够参与的输入和输出是文本内容.而想要让 GPT 完成各项功能,则需要对接现有的编程世界. ...

  3. 指定Task任务顺序执行

    经常听到说线程池这个东西,凭印象写了个这么简单的例子. CusTRun方法要不要await,取决于要不要作为后台任务.任务可指定数量,线程参数可共享全,顺序可控,可继续改进. using System ...

  4. 如何通过前后端交互的方式制作Excel报表

    前言 Excel拥有在办公领域最广泛的受众群体,以其强大的数据处理和可视化功能,成了无可替代的工具.它不仅可以呈现数据清晰明了,还能进行数据分析.图表制作和数据透视等操作,为用户提供了全面的数据展示和 ...

  5. 利用PostMan 模拟上传/下载文件

    我们经常用postman模拟各种http请求.但是有时候因为业务需要,我们需要测试上传下载功能.其实postman也是很好支持这两种操作的. 一.上传文件: 1.打开postman 选择对应reque ...

  6. su与sudo用法详解

    su与sudo用法详解 目录 su与sudo用法详解 1. su和sudo详解:切换用户身份 1.1 shell登录类型和环境配置文件 1.2 su进行身份切换 1.3 sudo命令详解 1.3.1 ...

  7. 第二届黄河流域网络安全技能挑战赛Web_wirteup

    前言 好久没写过比赛的wp了,黄河流域的web出的不错,挺有意思了,花了点时间,也是成功的ak了 myfavorPython 注册登录,一个base64输入框,猜测pickle反序列化,简单测试下,返 ...

  8. C语言:贮油点建设问题(详解题目意思)

    !!!!先看解析,后面附有代码!!!!!!! ,希望大家不懂的能认真看看,这些都是我在写的过程中不能理解,遇到的困难,然后弄懂之后总结出来给大家的,想学的一定要认真看完. 规律是: 贮油点之间相差50 ...

  9. 4G LTE/EPC UE 的附着与去附着

    目录 文章目录 目录 UE 附着 UE 与 MME 建立 NAS 连接 UE 附着协议全景 UE 附着流程 UE 去附着 UE 侧发起的去附着 MME 发起的去附着 HSS 发起的去附着 UE 附着 ...

  10. pageoffice在线打开word文件加盖电子印章

    一.加盖印章的 js 方法 js方法 二.常见使用场景 1.常规盖章.弹出用户名.密码输入框,选择对应印章. 点击盖章按钮弹出用户名密码登录框,登录以后显示选择电子印章. document.getEl ...