0
0
0
0
刘承志
中级光能
中级光能
高精度除法代码:
#include<limits>
#include<cstring>
#include<list>
#include<cstdio>
#include<iomanip>
#include<ios>
#include<iostream>
#include<istream>
#include<ostream>
#include<queue>
#include<set>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<cwchar>
#define N 1001
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
#define MAXSIZE 20
#define MAXOUTSIZE MAXSIZE * 2 + 1
using namespace std;
int a[101],b[101],c[101],d,i;
void shuru(int a[])
{
string s;
cin>>s;
a[0]=s.length();
for (i=1;i<=a[0];i++)
a[i]=s[a[0]-i]-'0';
}
void shuchu(int a[])
{
int i;
if (a[0]==0) {cout<<"0"<<endl;return;}
for (i=a[0];i>0;i--) cout<<a[i];
cout<<endl;
return;
}
int bijiao(int a[],int b[])
{
int i;
if (a[0]>b[0]) return 1;
if (a[0]<b[0]) return -1;
for (i=a[0];i>0;i--){if (a[i]>b[i]) return 1;if (a[i]<b[i]) return -1;}
return 0;
}
void jian(int a[],int b[])
{
int pd;
int i;
pd=bijiao(a,b);
if (pd==0) {a[0]=0;return;}
if (pd==1)
{
for (i=1;i<=a[0];i++)
{
if (a[i]<b[i]) {a[i+1]--;a[i]+=10;}
if (a[i]>=b[i]) a[i]-=b[i];
}
while((a[a[0]]==0)&&(a[0]>0)) a[0]--;
return;
}
}
void numcpy(int p[],int q[],int det)
{
for (int i=1;i<=p[0];i++) q[i+det-1]=p[i];
q[0]=p[0]+det-1;
}
void chugao(int a[],int b[],int c[])
{
int i,tmp[101];
c[0]=a[0]-b[0]+1;
for (i=c[0];i>0;i--)
{
memset(tmp,0,sizeof(tmp));
numcpy(b,tmp,i);
while (bijiao(a,tmp)>=0){c[i]++;jian(a,tmp);}
}
while((c[c[0]]==0)&&(c[0]>0)) c[0]--;
}
int main()
{
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
shuru(a);shuru(b);
chugao(a,b,c);
shuchu(c);
shuchu(a);
return 0;
}
第一行是商,第二行是余数
0
0
0
0
朱优扬
中级天翼
中级天翼
长整形:
long、long long、string(字符串)
我只知道高精度应该要用string,剩下不知道
朱优扬在2020-07-20 09:25:53追加了内容
长小数:
long double
0