90分求助

P1553 数字反转(升级版)

@[SeaClouds_MoonLight](/user/757076) 第19个测试点卡int 得开longlong
by ikun_god @ 2024-02-01 09:14:49


测试点三我实在不知道
by ikun_god @ 2024-02-01 09:15:52


@[ikun_god](/user/996255) 我好像不是这个问题,我全开的long long
by SeaClouds_MoonLight @ 2024-02-01 09:17:22


@[ikun_god](/user/996255) 整数部分用特别大的书测试,最后几位不一样
by SeaClouds_MoonLight @ 2024-02-01 09:18:05


[看看这个?](https://www.luogu.com.cn/discuss/748976)
by ikun_god @ 2024-02-01 09:18:31


`13274719835798134789571945980719823754981745979817540493738957813237498017238954790182375` 自己写的hank数据,你的代码似乎输出了负数。
by ikun_god @ 2024-02-01 09:22:02


还有这个也输出了负数`1238193981238188888818`
by ikun_god @ 2024-02-01 09:23:39


话说20位的数字long long也会炸
by ikun_god @ 2024-02-01 09:25:09


以及第六十行哪里 ``` for(ll i=30;i>=0;i--){ if(o[i-1]==10000005&&o[i]!=10000005){ s2+=pow(10,i)*o[i]; if(s2%10==0&&s2%100==0){ s2/=pow(10,i+1); }else{ s2/=pow(10,i); } break; } s2+=pow(10,i)*o[i]; } ``` 这里的pow会爆的(pow只支持结果在int范围内的乘方)
by ikun_god @ 2024-02-01 09:28:05


建议看看我的代码? ``` #include <bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int len=s.size(); int p1=s.find('.'); int p2=s.find('/'); int p3=s.find('%'); if (p1!=-1){ string left=s.substr(0,p1),right=s.substr(p1+1); int llen=left.size(); while (left[llen-1]=='0' && llen!=1){ llen-=1; } for (int i=llen-1;i>=0;--i){ cout<<left[i]; } cout<<"."; int z=0; while (right[z]=='0' && z!=right.size()-1){ z+=1; } for (int i=right.size()-1;i>=z;--i){ cout<<right[i]; } }else if (p2!=-1){ string left=s.substr(0,p2),right=s.substr(p2+1); int llen=left.size(),rlen=right.size(); while (left[llen-1]=='0' && llen!=1){ llen-=1; } for (int i=llen-1;i>=0;--i){ cout<<left[i]; } cout<<"/"; while (right[rlen-1]=='0' && rlen!=1){ rlen-=1; } for (int i=rlen-1;i>=0;--i){ cout<<right[i]; } }else if (p3!=-1){ while (s[len-2]=='0' && len!=2){ len-=1; } for (int i=len-2;i>=0;--i){ cout<<s[i]; } cout<<"%"; }else{ while (s[len-1]=='0' && len!=1){ len-=1; } for (int i=len-1;i>=0;--i){ cout<<s[i]; } } return 0; } ```
by ikun_god @ 2024-02-01 09:30:46


| 下一页