高精度 2.0

万众瞩目了
头图

image

在银河中孤独摇摆——知更鸟

Mend your pace, sway to the beat
加快步伐,紧随这律动摇摆
Hands up! Embrace who you wanna be
高举双手,拥理想自我入怀
We’re reaching heights unseen
我们一起抵达未见之境
Feel the fire deep within
感受着心底火焰
You’re the key to where my trust begins
你令我轻启心扉,交托信赖
Join-my-dream, it’s just the right time
加入我的梦境吧,大好时机已来
Leave it all behind
把一切都抛开
Get ready now
现在做好准备——
Rise
跃升
Up into my world
闯入我的世界
Renew your definition
更新你的定义
World so high, let me show
向你展示这里的超乎寻常
And hear my declaration
让你听见我的宣言
No more ties
“从此,再无拘束”
Off the ground and tap your feet
高高跳起,用双脚叩出节拍
Look, stars are near when you feel the beat
当你感受到律动,繁星已近在咫尺
We’re bound for a greater height
我们一起触碰更高的天空
Take a leap into the blazing,
要向炽燃中飞跃
Don’t lose yourself in mundanity
不在凡俗里沉沦
Join-my-dream, it is the right time
加入我的梦境吧,大好时机已来
Leave it all behind
把一切都抛开
Get ready now
现在做好准备
(Sing along)
(随我一起高唱)
Welcome to my world
欢迎来到我的世界
Renew your definition
更新你的定义
World so high, let me show
向你展示这里的超乎寻常
And hear my declaration
让你听见我的宣言
No more ties
“从此,再无拘束”
Welcome to my world
欢迎来到我的世界
Renew your definition
更新你的定义
World so high, let me show
向你展示这里的超乎寻常
Now hear my declaration
现在请静静地聆听
Welcome to my world
欢迎来到我的世界
Renew your definition
更新你的定义
World so high, we’ll show
我们要向世人证明这里的超乎寻常
and go beyond horizon
越过地平线
Side by side
肩并着肩


高精度板子 2.0

主要更新了 int 转数组的操作,目前有很大局限性,例如不能连续计算。会持续优化。

听你们的这次没用宏定义。

code:

#include<bits/stdc++.h>
using namespace std;
const int Ratio=0;
const int N=100005;
namespace WisaHighprecision
{
    int ayz,byz;
    int a[N],b[N],c[N],lena,lenb,lenc;
    void Wprepare()
    {
        memset(a,0,sizeof a);
        memset(b,0,sizeof b);
        memset(c,0,sizeof c);
        lena=lenb=0;
        while(ayz)
            a[lena++]=ayz%10,ayz/=10;
        while(byz)
            b[lenb++]=byz%10,byz/=10;
    }
    void WHPadd()
    {
        int x=0;
        lenc=max(lena,lenb);
        memset(c,0,sizeof c);
        for(int i=0;i<=lenc-1;i++)
            c[i]=a[i]+b[i]+x,
            x=c[i]/10,c[i]%=10;
        if(x)
            c[++lenc-1]=x;
    }
    bool Wcheck()
    {
        if(lena<lenb)
            return false;
        else if(lena>lenb)
            return true;
        else
        {
            int flag=0;
            for(int i=lena-1;i>=0;i--)
                if(a[i]<b[i])
                    return false;
            return true;
        }
    }
    void WHPsub()
    {
        lenc=max(lena,lenb);
        if(!Wcheck())
        {
            printf("-");
            for(int i=0;i<lenc;i++)
            {
                if(b[i]<a[i])
                    b[i+1]--,b[i]+=10;
                c[i]=b[i]-a[i];
            }
            while(!c[lenc-1]) lenc--;
        }
        else
        {
            for(int i=0;i<lenc;i++)
            {
                if(a[i]<b[i])
                    a[i+1]--,a[i]+=10;
                c[i]=a[i]-b[i];
            }
            while(!c[lenc-1])
            {
                if(lenc==1)
                    break;
                lenc--;
            }
        }
    }
    void WHPmul()
    {
        if((lena==1&&a[0]==0)||(lenb==1&&b[0]==0))
        {
            c[0]=0,lenc=1;
            return;
        }
        lenc=lena+lenb;
        for(int i=0;i<lena;i++)
            for(int j=0;j<lenb;j++)
                c[i+j]+=a[i]*b[j],
                c[i+j+1]+=c[i+j]/10,
                c[i+j]%=10;
        while(!c[lenc-1]) lenc--;
    }
    short main()
    {
        cin>>ayz>>byz;
        Wprepare();
        // Choose your function:
        // WHPadd();
        // WHPsub();
        // WHPmul();
        for(int i=lenc-1;i>=0;i--)
            cout<<c[i];cout<<'\n';
        return Ratio;
    }
}
int main(){return WisaHighprecision::main();}

updating。。。

posted @ 2024-06-14 16:25  DrRatio  阅读(55)  评论(2编辑  收藏  举报