60求条
  • 板块P1001 A+B Problem
  • 楼主lcpwp
  • 当前回复1
  • 已保存回复1
  • 发布时间2025/7/23 16:44
  • 上次更新2025/7/23 16:51:45
查看原帖
60求条
1771759
lcpwp楼主2025/7/23 16:44

?我高精都过了这咋没过?

#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iomanip>
#include <algorithm>
#include <vector>
#define int long long
//#include<bits/stdc++.h>

using namespace std;

string add(string a,string b){
	int len=max(a.size(),b.size());
	while (a.size()<len)a='0'+a;
	while (b.size()<len)b='0'+b;
	int al=a.length(),bl=b.length();
	string j;
	int jw=0;
	for(int i=len-1;i>=0;i--){
		int t1=a[i]-'0';
		int t2=b[i]-'0';
		int t=t1+t2+jw;
		jw=t/10;
		t%=10;
		char c=t+'0';
		j=c+j;
	}
	if(jw>0){
		return '1'+j;
	}return j;
}
signed main(){
	string a,b;
	cin>>a>>b;
	cout<<add(a,b);
} 
2025/7/23 16:44
加载中...