使用说明:

  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. 用python编写向通信产品发送AT指令的程序实例

    一.安装pyserial包pip install pyserial 二.实例代码 # -*- coding: utf-8 -*- import time import hashlib from ser ...

  2. dotnet 6 使用 DependentHandle 关联对象生命周期

    本文将告诉大家在 dotnet 6 新加入的 System.Runtime.DependentHandle 的类型的使用方法,通过 DependentHandle 可以实现将某个对象的引用生命周期和另 ...

  3. OLAP系列之分析型数据库clickhouse主从副本模式(三)

    一.测试单分片,单副本或多副本模式 # 1.停止集群 systemctl stop clickhouse-server # 修改配置文件 vim /etc/clickhouse-server/conf ...

  4. 高性能消息中间件-Nats使用

    一.Nats简介 官网:https://nats.io/ 官网下载:https://nats.io/download/ github:https://github.com/nats-io/nats-s ...

  5. zabbix-server-pgsql docker镜像说明

    0 说明 zabbix-server-pgsql在docker hub的官方说明,供查阅 1 Environment Variables 1.1 基本变量 When you start the zab ...

  6. Cesium的HeadingPitchRange 用法

    这个有别于headingpitchroll, headingpitchroll是用在orientation属性上的(比如相机的setView,flyTo,以及entities.add中) Headin ...

  7. three.js 物体要使用光线投射技术,计算是否点击位置与物体有交叉

    原生 DOM 还用原生的 DOM 点击事件,要注意开启 pointerEvents CSS3DRenderer 是一个新的渲染器,需要在渲染循环调用并适配 labelRenderer.domEleme ...

  8. 2022年windows的Visual Studio常用插件及使用手册

    前景提要 Viusual Studio 是一款很好用的C/C++集成开发工具,具有强大的扩展功能,好用的插件,但是,很多人都是只写了有什么插件,但是,没写怎么使用这种插件,使得使用的时候很是不方便,所 ...

  9. 内网渗透 Metasploit(MSF)基础使用

    免责申明 以下内容仅供学习使用,非法使用造成的问题由使用人承担 攻击思路 漏洞探测(信息收集) <- fsacn,namp | 漏洞利用 <- 工具(msf等) | 获取服务器权限 MSF ...

  10. NFS共享文件

    NFS共享文件 服务端 安装NFS [root@localhost www] yum -y install nfs-utils rpcbind 创建需要共享的文件夹share [root@localh ...