题解
2023-09-18 19:12:48
发布于:浙江
这道题十分深奥,因为作者可能会坑我们。所以,我们要用高精度。代码如下:
#include<bits/stdc++.h>
#define N 210
using namespace std;
int as[N],bs[N],lena,lenb;
string a,b;
int main(){
cin>>a>>b;
lena=a.size();
lenb=b.size();
for(int i=0;i<lena;i++)as[i]=a[lena-i-1]-'0';
for(int i=0;i<lenb;i++)bs[i]=b[lenb-i-1]-'0';
int length=max(lena,lenb);
for(int i=0;i<length;i++)as[i]+=bs[i];
for(int i=0;i<length;i++){
if(as[i]>9){
as[i+1]++;
as[i]-=10;
if(i==length-1)length++;
}
}
while(length&&as[length]==0)length--;
for(int i=length;i>=0;i--)cout<<as[i];
cout<<endl;
}
看完代码,加入我的团队吧!
中国人民解放军
全部评论 42
看我别忘了点赞哦~
2023-09-18 来自 浙江
146
原本两三行的代码
硬生生写到了几十行
不愧是大佬
(doge2023-09-25 来自 四川
1就这?????????????
#include<iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#include<string>
#include<cstring>
#include<list>
#include<map>
#include<queue>
#include<iterator>
#include<stack>
using namespace std;#define ll long long
const int N = 1010;int RAND_1(ll a,ll b){
ll n = a + b;
return n;
}int RAND_2(string a, string b, int n[500], int m[500], int ans[501]){
for(int i = 0; i < a.size(); i++)
n[i] = a[a.size() - i - 1] - '0';
for(int i = 0; i < b.size(); i++)
m[i] = b[b.size() - i - 1] - '0';
int len_maxn = max(a.size(), b.size()) + 1;
for(int i = 0; i < len_maxn; i++)
{
ans[i] = n[i] + m[i] + ans[i];
if(ans[i] > 9)
{
ans[i + 1]++;
ans[i] = ans[i] % 10;
}
}
while(ans[len_maxn - 1] == 0 && len_maxn > 0) len_maxn--;
for(int i = len_maxn - 1; i >= 0; i--) cout << ans[i];
return 0;
}int RAND_3(ll a, ll b){
ll ans = 0;
for(int i = 0; i < a; i ++ ) {
ans ++;
}
for(int i = 0; i < b; i ++ ) {
ans ++;
}
return ans;
}int n[1010], m[1010],c[1010];
int main(){
srand(time(0));
ll a , b;
string z , y;
int x;
x = 1 + rand() % 3;
if(x == 1){
cin >> a >> b;
int ans = RAND_1(a,b);
cout << ans;
}
if(x == 2){
cin >> z >> y;
RAND_2(z , y , n , m, c);
}
if(x == 3){
cin >> a >> b;
int ans = RAND_3(a, b);
cout << ans;
}
return 0;
}2024-11-03 来自 广东
2(狗式点头)
2025-01-26 来自 浙江
0
还用高精度……
2023-09-18 来自 浙江
26,小号吸引流量
2025-06-29 来自 浙江
0
这个有意思,6
2023-09-18 来自 浙江
2大佬



2026-02-15 来自 江苏
1
1周前 来自 广东
0https://www.acgo.cn/team/1996488676259516416
2026-05-26 来自 浙江
0#include<bits/stdc++.h>
using namespace std;
int a[1005],b[1005],c[1005];
int main(){
string s1,s2;
cin>>s1>>s2;
bool flag=0;
int alen=s1.length(),blen=s2.length(),clen;
for(int i=0;i<alen;i++){
a[i]=s1[alen-i-1]-'0';
}
for(int i=0;i<blen;i++){
b[i]=s2[blen-i-1]-'0';
}
clen=max(alen,blen);
for(int i=0;i<clen;i++){
c[i]+=a[i]+b[i];
if(c[i]>9){
c[i+1]=1;
c[i]%=10;
}
}
if(c[clen]1) clen++;
for(int i=0;i<clen;i++){
if(flag0&&c[clen-1-i]==0) continue;
else{
cout<<c[clen-1-i];
flag=1;
}
}
return 0;
}2026-05-23 来自 贵州
0搞得我都懵了
2026-04-19 来自 浙江
0
2026-04-19 来自 河北
0方法没错
2026-04-04 来自 浙江
01234
2026-04-02 来自 浙江
0厉害
2026-03-28 来自 江苏
01
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
12026-03-22 来自 江苏
0?
2026-03-19 来自 浙江
0n
2026-03-14 来自 浙江
0ok
2026-03-12 来自 浙江
0ok
2026-03-12 来自 浙江
0ok
2026-03-10 来自 浙江
0@ppl_cjdst(92134) 你会坑他吗
2026-02-28 来自 上海
0想的可能也太多了
2026-02-26 来自 福建
0









































有帮助,赞一个