当前位置:网站首页>高精度压位模板
高精度压位模板
2022-06-21 16:03:00 【eliforsharon】
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#define inf 1000000000]
#define p 9 //注意乘法压位过大
using namespace std;
void _scanf(int &x){
char ch=getchar();
bool f=0;
x=0;
while(!isdigit(ch)) {
if(ch=='-') f=1;
ch=getchar();
}
while(isdigit(ch)) x=10*x+ch-'0',ch=getchar();
if(f) x=-x;
}
void _scanf(int &a,int &b){
_scanf(a);
_scanf(b);
}
struct bign{
int z[25],len;
bign(){
memset(z,0,sizeof(z));
len=0;
}
bign (int x){
*this=x;
}
bign operator =(int x){
char s[25];
sprintf(s,"%d",x);
*this=s;
}
bign operator =(char *s){
int len=strlen(s);
int cur=0;
bign a;
char w[25];
while(len>0){
while(len>=p){
strcpy(w,s+len-p);
a.z[cur++]=atoi(w);
len-=p;
}
if(len>0){
strcpy(w,s);
w[len]='\0';
a.z[cur++]=atoi(w);
len=0;
}
}
a.len=cur;
*this=a;
}
friend bign operator +(bign a,bign b){
bign c;
int len=max(a.len,b.len)+1;
for(int i=0;i<=len-1;i++){
c.z[i]=a.z[i]+b.z[i];
}
for(int i=0;i<=len-1;i++)
c.z[i+1]+=c.z[i]/1000000000,c.z[i]%=1000000000;
while(c.z[len-1]==0&&len>1) len--;
c.len=len;
return c;
}
};void bignout(bign a){
int len=a.len;
printf("%d",a.z[len-1]);
for(int i=len-2;i>=0;i--)
printf("%0*d",p,a.z[i]);
}边栏推荐
- [1108. Invalidation de l'adresse IP]
- Beaucoup de sociétés de logiciels sont en fait des "blagues"
- [issue 349] Interviewer: how to gracefully customize the ThreadPoolExecutor thread pool?
- 栈的生长方向和内存生长方向
- 建立自己的网站(11)
- 新增Razor组件支持代理连接RDP,JumpServer堡垒机v2.23.0发布
- 【mysql学习笔记13】查询语句综合练习
- 【Leetcode】297. Serialization and deserialization of binary tree (difficult)
- [ros2 basics] Introduction to navigation2 navigation system
- 2022年第三届全国运筹学/数据、模型与决策课程教学研讨会通知
猜你喜欢

很多软件公司,其实都是“笑话”

Concept drift in machine learning (Apria)

面向流动人口管理的人脸验证系统设计及实现 论文+答辩PPT+项目工程文件

Postman basic operations

Detailed explanation of Fisher information quantity detection countermeasure sample code

Beaucoup de sociétés de logiciels sont en fait des "blagues"

【mysql学习笔记15】用户管理

Elegant request retry using guzzle Middleware

Test log of unittest framework

牛客网:大数加法
随机推荐
Week 13 summary blog (week 15 of the school calendar) dynamic planning summary
大话内存四区
使用unittest框架生成测试报告
Fidder tool usage notes
[从零开始学习FPGA编程-38]:进阶篇 -语法-函数与任务
The beta version of move protocol is stable, and it is temporarily decided to expand the scale of the prize pool
Design and implementation of face verification system for floating population management
Mqtt of NLog custom target
Set up your own website (11)
栈的生长方向和内存生长方向
设计一个打印整棵树的打印函数
Move Protocol Beta测试版稳定,临时决定奖池规模再扩大
Pytest框架
How to judge DNS resolution failure? How to resolve DNS resolution errors?
Postman basic operations
Sword finger offer II 089 House theft / Sword finger offer II 090 Ring house theft
Machine learning model monitoring (Apria)
容器云是什么意思?与堡垒机有什么区别?
MATLAB实现的基于对称TSP问题研究
Unittest框架