求解这是什么鬼

P1919 【模板】高精度乘法 | A*B Problem 升级版

大佬求救……
by Iowa_BattleShip @ 2017-11-06 15:29:16


有dalao么 蒟蒻求救……
by Iowa_BattleShip @ 2017-11-06 15:39:22


不是dalao 我这里也错了 不过是re 不知为啥
by Leaves_Flower @ 2017-11-06 15:43:34


windows和linux运行结果可能不一致,建议在洛谷在线IDE运行试试,有一次我就是因为操作系统差异,调KMP调了一天
by lrj124 @ 2017-11-06 15:51:03


我来帮你
by 沫白 @ 2017-11-06 16:20:11


@[流叶](/space/show?uid=41186) @[lrj124](/space/show?uid=17521) 感谢,我在洛谷IDE上调了半小时,发现这东西在我重载的函数里面都是正确的,然后一返回就全部变成0……一脸懵逼什么鬼东西……弄了好久都没法,逼得我直接在重载函数里输出,现在A了,感谢帮助,感谢还有人理我QAQ
by Iowa_BattleShip @ 2017-11-06 16:20:46


@[沫白](/space/show?uid=36651) 感谢有人愿意帮我,我现在已经A了,不过谢谢您的好意
by Iowa_BattleShip @ 2017-11-06 16:22:32


一直3个re 本地也挺好的 下了第2个点的数据 输出的和你那个一样 ```cpp #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string> #include <vector> #define LEN 100000000 using namespace std; const int N=8005; char s1[N],s2[N]; struct int_l{ long long data[N]; int_l(){ memset(data,0,sizeof(data));data[0]=1; } int_l(string &x){ memset(data,0,sizeof(data)); int len=1,t=1,temp=1,nowlen=0; int l=x.length(); while(t <= l){ nowlen++; data[len]+=(x[l-t]-'0')*temp; t++; if(nowlen>8){ data[len+1]=data[len]/LEN; data[len]%=LEN; len++; temp=1; nowlen=1; } temp*=10; } data[0]=len; } // int_l operator +(const int_l &x){ // int_l a; // a.data[0]=max(data[0],x.data[0]); // for(int i=1;i <= a.data[0];i++) // a.data[i]=data[i]+x.data[i]; // for(int i=1;i <= a.data[0];i++) // a.data[i+1]+=a.data[i]/LEN, // a.data[i]%=LEN; // if(a.data[a.data[0]+1]) a.data[0]++; // return a; // } int_l operator *(const int_l &x){ int_l a; a.data[0]=data[0]+x.data[0]; for(int i=1;i <= data[0];i++) for(int j=1;j <= x.data[0];j++){ a.data[i+j-1]+=data[i]*x.data[j]; a.data[i+j]+=a.data[i+j-1]/LEN; a.data[i+j-1]%=LEN; } if(!a.data[a.data[0]]) a.data[0]--; print(a); return a; } void print(const int_l &x){ for(int i=x.data[0];i >= 1;i--){ if (i==x.data[0]) printf("%lld",x.data[i]); else printf("%08lld",x.data[i]); } cout<<endl; } }; istream& operator >>(istream &in ,int_l &x){ string s; in>>s; x=s; return in; } int_l a,b,ans; int n; int main(){ // freopen("testdata(1).in","r",stdin); // freopen("testdataok.out","w",stdout); cin>>n; // scanf("%s%s",&s1,&s2); cin>>a>>b; // print(a); // print(b); a*b; // print(ans); return 0; } @[Iowa_BattleShip](/space/show?uid=60181) ```
by Leaves_Flower @ 2017-11-06 16:55:27


@[流叶](/space/show?uid=41186) 压8位的话重载里数组要大于15000,因为数据最大60000,压8位要7500,乘积最大有15000位
by Iowa_BattleShip @ 2017-11-06 17:21:19


@[流叶](/space/show?uid=41186) 这是我的代码,你可以参考一下(蒟蒻表示不会FFT,只能压位= =) ```cpp #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; char q[71000],qq[71000]; struct big{ static const int base=100000000; static const int w=8; ll s[16000],l; big() { l=-1; } big operator = (const big& b) { for(ll i=0;i<=9999;i++) s[i]=b.s[i]; l=b.l; return *this; } big operator = (ll num) { for(ll i=0;i<=9999;i++) s[i]=0; l=-1; do { s[++l]=num%base; num/=base; }while(num>0); return *this; } big operator * (const big& b) { big c; ll x=0,i,j; c=x; c.l=-1; for(i=0;i<=l;i++) { x=0; for(j=0;j<=b.l;j++) { c.s[i+j]=s[i]*b.s[j]+x+c.s[i+j]; x=c.s[i+j]/base; c.s[i+j]%=base; } c.s[i+b.l+1]=x; } c.l=l+b.l+1; while(!c.s[c.l]&&c.l>0) c.l--; printf("%lld",c.s[c.l]);//不知道为什么计算时里面c都是正确的,一到外面的n就全是0了,所以我只能在函数内输出 for(i=c.l-1;i>=0;i--) printf("%08lld",c.s[i]); return c; } }; big n,m,a; ll ksm(ll x) { ll i=10,s=1; for(;x;x>>=1,i*=i) if(x&1) s*=i; return s; } int main() { ll x=0,y,i,k=0; scanf("%lld%s%s",&y,q,qq); for(i=strlen(q)-1;i>=0;i--) { x=x+(q[i]-'0')*ksm(k); k++; if(k==8) { n.s[++n.l]=x; k=x=0; } } if(k) n.s[++n.l]=x; k=x=0; for(i=strlen(qq)-1;i>=0;i--) { x=x+(qq[i]-'0')*ksm(k); k++; if(k==8) { m.s[++m.l]=x; k=x=0; } } if(k) m.s[++m.l]=x; m*n; return 0; } ```
by Iowa_BattleShip @ 2017-11-06 17:26:30


| 下一页