houyunjie @ 2024-08-26 19:40:13
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int a[50000000],b[50000000],c[100000019];
int l;
int main(){
cin >> s1 >> s2;
for(int i = 0;i < s1.size();i++){
a[s1.size () - i - 1] = s1[i] - '0';
}
for(int i = 0;i < s2.size();i++){
b[s2.size () - i - 1] = s2[i] - '0';
}
l = s1.size();
if(s2.size() > l){
l = s2.size();
}
for(int i = 0;i < l;i++){
c[i]=a[i] + b[i];
}
for(int i = 0;i < l;i++){
if(c[i]>=10){
c[i + 1] = c[i + 1] + c[i] / 10;
c[i]%=10;
}
}
if(c[l] != 0){
l++;
}
for(int i = l - 1;i >= 0; i--){
cout<<c[i];
}
return 0;
}
by 12345698pP @ 2024-08-26 20:03:11
@cff_0102 我们都知道了
by Xianzi_ @ 2024-08-26 20:05:22
P1001 不是高精度。 P1601才是高精度的 A + B Problem。
by liuhaohe @ 2024-08-27 08:59:55
@houyunjie
#include<iostream>
using namespace std;
int main()
{
int a,b;
cin>>a,b;
cout<<a+b;
}
by liuhaohe @ 2024-08-27 09:00:57
@houyunjie 直接输出
by 13986586309hap @ 2024-08-27 21:30:25
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x,y;
cin >> x >> y;
cout << (x + y);
return 0;
}
AC代码
by llhhss @ 2024-09-03 19:40:09
你这太复杂了看我的
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
cout<<a+b;
return 0;
}
by MasonChong @ 2024-09-05 20:47:07
有负数,高精不行
by Soyeon @ 2024-09-10 12:44:20
@houyunjie 大袜子你...... 入门就这么卷吗