40分下载数据本地运行没错但提交错了

P1601 A+B Problem(高精)

没考虑最后有进位 hack: 输入: 1 9 输出: 0
by Null_h @ 2023-08-30 15:06:03


@[kdqs8218](/user/705712) 这个问题解决了但还是四十分捏
by slowspeed @ 2023-08-30 15:15:17


if(RE){ 13,17行改为'0' }else if(WA){ 21行用string可能有误 }
by Null_h @ 2023-08-30 15:20:03


```c #include <bits/stdc++.h> #define ll long long using namespace std; string a,b,c; int temp=0; int main(){ cin>>a>>b; ll lena=a.length(); ll lenb=b.length(); ll max_=max(lena,lenb); if(lena<lenb){ for(ll i=0;i<lenb-lena;i++){ a='0'+a; } }else if(lenb<lena){ for(ll i=0;i<lena-lenb;i++){ b='0'+b; } } ll temp1=0; for(ll i=0;i<max_;i++){ temp1=(a[max_-1-i]-'0')+(b[max_-i-1]-'0')+temp; temp=temp1/10; temp1=temp1%10; c=char(temp1+'0')+c; } if(temp){ cout<<temp; } cout<<c; return 0; } /* 123 12 */ ``` @[kdqs8218](/user/705712) 改成很奇怪的这样才过的,谢谢大牢(●ˇ∀ˇ●)
by slowspeed @ 2023-08-30 15:35:23


|