新人求助,本机RE,提交AC?

P2000 拯救世界

```cpp #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<cmath> #include<vector> #include<queue> #define N 1000003 #define p 998244353 #define reg register #define ll long long using namespace std; struct BigInt{ int num[N]; int size; bool negative; bool operator < (const BigInt& a) const{ if(a.negative&&!negative) return false; if(negative&&!a.negative) return true; if(size!=a.size) return size<a.size; bool f = negative; for(int i=size;i>=1;--i){ if(a.num[i]==num[i]) continue; if(f) return num[i]>a.num[i]; else return num[i]<a.num[i]; } return false; } bool operator > (const BigInt& a) const{ if(a.negative&&!negative) return true; if(negative&&!a.negative) return false; if(size!=a.size) return size>a.size; bool f = negative; for(int i=size;i>=1;--i){ if(a.num[i]==num[i]) continue; if(!f) return num[i]>a.num[i]; else return num[i]<a.num[i]; } return false; } bool operator == (const BigInt& a) const{ if(negative!=a.negative) return false; if(size!=a.size) return false; for(int i=size;i>=1;--i) if(num[i]!=a.num[i]) return false; return true; } }; int rev_[N],F[N],G[N]; inline int power(int a,int t){ int res = 1; while(t){ if(t&1) res = (ll)res*a%p; a = (ll)a*a%p; t >>= 1; } return res; } void NTT(int *a,int type,int lim){ for(int i=0;i<=lim;++i){ if(i>=rev_[i]) continue; swap(a[i],a[rev_[i]]); } for(int mid=1;mid<lim;mid<<=1){ int rt = power(3,(p-1)/(mid<<1)); if(type==-1) rt = power(rt,p-2); int r = mid<<1; for(int j=0;j<lim;j+=r){ int w = 1; for(int k=0;k<mid;++k){ int x = a[j+k]; int y = (ll)w*a[j+k+mid]%p; a[j+k] = (x+y)%p; a[j+k+mid] = ((x-y)%p+p)%p; w = (ll)w*rt%p; } } } } inline BigInt newBigInt(string n){ int t = 0; BigInt a; memset(a.num,0,sizeof(a.num)); a.size = n.length(); if(n[0]=='-'){ t = 1; a.size--; } for(int i=1;i<=a.size;++i) a.num[i] = n[a.size-i+t]-'0'; a.negative = (t==0)?false:true; return a; } inline BigInt toBigInt(int a){ BigInt b = newBigInt("0"); int l = 1; if(a<0){ a = -a; b.negative = true; } while(a){ b.num[l] = a%10; a /= 10; ++l; } b.size = l-1; return b; } const BigInt ZERO = newBigInt("0"); const BigInt ONE = newBigInt("1"); const BigInt TWO = newBigInt("2"); const BigInt TEN = newBigInt("10"); void print(BigInt a){ int l = a.size; if(a.negative) putchar('-'); for(int i=l;i>=1;--i) putchar(a.num[i]+'0'); } BigInt add(BigInt a,BigInt b); BigInt subtract(BigInt a,BigInt b); BigInt multiply(BigInt a,BigInt b){ int l,n,m,lim,cnt; if(a==ZERO||b==ZERO) return ZERO; BigInt c = ZERO; cnt = l = 0; lim = 1; n = a.size-1; m = b.size-1; memset(F,0,sizeof(F)); memset(G,0,sizeof(G)); for(reg int i=0;i<=n;++i) F[i] = a.num[i+1]; for(reg int i=0;i<=m;++i) G[i] = b.num[i+1]; cnt = n+m; while(lim<=cnt){ lim <<= 1; ++l; } for(reg int i=0;i<lim;++i) rev_[i] = (rev_[i>>1]>>1)|((i&1)<<(l-1)); NTT(F,1,lim); NTT(G,1,lim); for(reg int i=0;i<=lim;++i) F[i] = (ll)F[i]*G[i]%p; NTT(F,-1,lim); int inv = power(lim,p-2); for(reg int i=0;i<=cnt;++i) c.num[i+1] = (ll)F[i]*inv%p; ++cnt; for(reg int i=1;i<=cnt;++i){ if(c.num[i]<10) continue; c.num[i+1] += c.num[i]/10; c.num[i] %= 10; } while(c.num[cnt+1]>0) ++cnt; int i = cnt; while(c.num[i]==0) --i; c.size = i; c.negative = a.negative^b.negative; return c; } BigInt add(BigInt a,BigInt b){ BigInt c = ZERO; if(a.negative&&b.negative){ a.negative = false; b.negative = false; c = add(a,b); c.negative = true; return c; }else if(a.negative&&!b.negative){ a.negative = false; c = subtract(b,a); return c; }else if(!a.negative&&b.negative){ b.negative = false; c = subtract(a,b); return c; } int l = max(a.size,b.size); for(int i=1;i<=l;++i) c.num[i] = a.num[i]+b.num[i]; for(int i=1;i<=l;++i){ if(c.num[i]<10) continue; c.num[i+1]++; c.num[i] -= 10; } c.size = l; if(c.num[l+1]!=0) c.size++; return c; } BigInt _divide(BigInt a,int b){ bool flag = false; if(b<0){ flag = true; b = -b; } BigInt c = ZERO; if(a<toBigInt(b)) return c; int l,n = a.size; l = n; while(a.num[n]<b&&l>=1){ a.num[n-1] += (a.num[n]<<3)+(a.num[n]<<1); a.num[n] = 0; --n; } for(int i=n;i>=1;--i){ if(a.num[i]>=b){ c.num[i] = a.num[i]/b; a.num[i] %= b; } a.num[i-1] += (a.num[i]<<3)+(a.num[i]<<1); } c.size = n; c.negative = a.negative^flag; return c; } BigInt subtract(BigInt a,BigInt b){ BigInt c = ZERO; if(a.negative&&!b.negative){ a.negative = false; c = add(a,b); c.negative = true; return c; }else if(a.negative&&b.negative){ a.negative = false; b.negative = false; return subtract(b,a); }else if(!a.negative&&b.negative){ b.negative = false; c = add(a,b); c.negative = false; return c; } if(a<b){ c = subtract(b,a); c.negative = true; return c; }else if(a==b) return c; int l = max(a.size,b.size); for(int i=1;i<=l;++i) c.num[i] = a.num[i]-b.num[i]; for(int i=1;i<=l;++i){ if(c.num[i]>=0) continue; c.num[i] += 10; c.num[i+1]--; } while(!c.num[l]) --l; if(l==0) l = 1; c.size = l; return c; } BigInt power(BigInt a,int t){ bool flag = false; BigInt b = ONE; if(t&1&&a.negative) flag = true; while(t){ if(t&1) b = multiply(a,b); a = multiply(a,a); t >>= 1; } a.negative = flag; return b; } BigInt _mod(BigInt a,int b){ BigInt c = _divide(a,b); c = multiply(toBigInt(b),c); c = subtract(a,c); return c; } inline BigInt Abs(BigInt a){ a.negative = false; return a; } BigInt n,ans; string a; int main(){ cin>>a; n = newBigInt(a); ans = multiply(add(n,ONE),add(n,TWO)); n = add(n,TWO); ans = multiply(ans,add(n,ONE)); ans = multiply(ans,add(n,TWO)); ans = _divide(ans,24); print(ans); return 0; } ```
by NaCly_Fish @ 2019-02-28 19:11:43


~~令我疑惑的是,为什么在本机都已经RE了,竟然还敢提交?~~
by RiverFun @ 2019-02-28 19:13:18


~~令我疑惑的是,为什么在本机都已经RE了,竟然还敢提交?~~
by Imakf @ 2019-02-28 19:13:40


~~令我疑惑的是,为什么在本机都已经RE了,竟然还敢提交?~~
by 豌豆射手皮0608 @ 2019-02-28 19:15:20


~~令我疑惑的是,为什么在本机都已经RE了,竟然还敢提交?~~
by LTb_ @ 2019-02-28 19:16:53


~~令我疑惑的是,为什么在本机都已经RE了,竟然还敢提交?~~
by WYXkk @ 2019-02-28 19:19:00


令我疑惑的是,为什么在本机都已经RE了,竟然还敢提交?
by Siyuan @ 2019-02-28 19:19:34


~~令我疑惑的是,为什么在本机都已经RE了,竟然还敢提交?~~
by StudyingFather @ 2019-02-28 19:20:00


@[Siyuan](/space/show?uid=49725) 您忘了加删除线了QAQ
by NaCly_Fish @ 2019-02-28 19:21:41


~~令我疑惑的是,为什么在本机都已经RE了,竟然还敢提交?~~
by lightup37 @ 2019-02-28 21:53:13


| 下一页