我到底错哪儿了啊?!
2026-05-09 20:52:04
发布于:浙江
嗯对,
就是我到底错哪儿了啊?!
原题
#include<bits/stdc++.h>
typedef long long ll;
const ll M=1000000000LL;
struct X{
static void C(ll n){
if(n<0){
throw 1;
}
if(n>M){
throw 1;
}
}
};
struct I{
static pair<ll,ll>G(){
if(!cin){
throw 2;
}
string s;
getline(cin,s);
if(s.empty()){
throw 3;
}
istringstream i(s);
ll a,b;
if(!(i>>a)){
throw 4;
}
if(!(i>>b)){
throw 5;
}
string t;
if(i>>t){
throw 6;
}
X::C(a);
X::C(b);
return{a,b};
}
};
struct D{
vector<int>f(ll n){
vector<int>v;
if(n<0){
throw 7;
}
if(n==0){
v.push_back(0);
return v;
}
while(n>0){
int k=n%10;
v.push_back(k);
n=n/10;
}
if(v.empty()){
throw 8;
}
reverse(v.begin(),v.end());
return v;
}
ll w(vector<int>v){
if(v.empty()){
throw 9;
}
ll r=0;
int L=v.size();
for(int o=0;o<L;o++){
if(v[o]<0||v[o]>9){
throw 10;
}
r=r*10;
r=r+v[o];
if(r<0){
throw 11;
}
}
return r;
}
ll a(ll x,ll y){
auto d1=f(x);
auto d2=f(y);
vector<int>z;
int c=0;
int i=d1.size()-1;
int j=d2.size()-1;
while(1){
if(i<0&&j<0&&c==0){
break;
}
int p=0;
if(i>=0){
p=d1[i];
i--;
}
int q=0;
if(j>=0){
q=d2[j];
j--;
}
int t=p+q+c;
if(t<0){
throw 12;
}
c=t/10;
int m=t%10;
z.push_back(m);
}
if(z.empty()){
throw 13;
}
reverse(z.begin(),z.end());
return w(z);
}
};
struct S{
D d;
ll c(ll a,ll b){
ll res=d.a(a,b);
if(res<0){
throw 14;
}
return res;
}
};
struct A{
void r(){
auto[x,y]=I::G();
S s;
ll t=s.c(x,y);
if(!cout){
throw 15;
}
cout<<t<<endl;
}
};
struct B{
A a;
void u(){
a.r();
}
};
struct C{
B b;
void m(){
b.u();
}
};
struct F{
C c;
void k(){
c.m();
}
};
struct H{
F f;
void g(){
f.k();
}
};
struct J{
H h;
void l(){
h.g();
}
};
int main(){
try{
J j;
j.l();
}catch(int){
return 1;
}
return 0;
}
全部评论 5
- 置顶
坏了,想开 cnfy 发现没证据证明这是 AI

4天前 来自 上海
2这是我自己做的哈

3天前 来自 浙江
1bushi AI
3天前 来自 浙江
1
有没有大佬帮忙纠错

3天前 来自 浙江
1何意味
4天前 来自 广东
1这何意味
4天前 来自 浙江
1这题..........................................................
















4天前 来自 天津
1不难
3天前 来自 浙江
1































有帮助,赞一个