yinjunjie2012 @ 2024-08-23 09:35:02
#include<bits/stdc++.h>
using namespace std;
int main(){
char a[100010],b[100010];
cin>>a>>b;
int a1[100010],b1[100010],la=strlen(a),lb=strlen(b);
for(int i=0;i<la;i++)a1[i]=a[la-i-1]-48;
for(int i=0;i<lb;i++)b1[i]=b[lb-i-1]-48;
int c1[100010],lc=max(la,lb)+1;
int x=0;
for(int i=0;i<lc;i++){
c1[i]=a1[i]+b1[i]+x;
x=c1[i]/10;
c1[i]%=10;
}
int flag=0;
for(int i=lc;i>=0;i--){
if(flag==0 and c1[i]==0){
continue;
}
if(flag==0 and c1[i]!=0){
cout<<c1[i];
flag=1;
}
else{
cout<<c1[i];
}
}
return 0;
}
by jiangyixuan_eason @ 2024-08-28 12:49:11
这样不就行了吗,其实完全不用那么复杂呀
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin >>a>>b;
cout <<a+b<<endl;
return 0;
}
by guimei121212 @ 2024-08-30 18:52:17
@yinjunjie2012 像你这样用高精度做P1601双倍经验哦
by AAAbbb12321 @ 2024-09-06 20:02:05
额
by Liuchuhao @ 2024-10-20 16:20:20
print(int(inpit())+int(input()))
使用python,无惧高精度
违规紫杉
by Lucashuang @ 2024-11-03 13:19:44
#include<bits/stdc++.h>
using namespace std;
int m , n , a[200001] , l1 , s , r1 , maxx = 0 , ans;
priority_queue<int> que;
int fen(int l , int r){
if(l == r) return a[l];
m = (l + r) / 2;
s = a[m] , l1 = a[m] , r1 = a[m + 1];
for(int i = m - 1; i >= l; i--){
s += a[i];
l1 = max(l1 , s);
}
int s1 = a[m + 1];
for(int i = m + 2; i <= r; i++){
s1 += a[i];
r1 = max(r1 , s1);
}
return max(max(fen(l , m) , fen(m + 1 , r)) , l1 + r1);
}
bool check(int k){
for(int i = 1; i <= n; i++){
que.push(a[i]);
}
while(!que.empty()){
k -= que.top();
que.pop();
}
if(k){
return true;
} else {
return false;
}
}
int f(int n){
if(n == 1) return a[1];
return a[n] + f(n - 1);
}
int main(){
int n = 2 , ans;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
ans = fen(1 , n);
if(check(ans)){
if(f(n) == ans){
cout << ans;
} else {
cout << "Wrong!";
}
} else {
cout << "Wrong!";
}
return 0;
}