首页 > 代码库 > 清北学堂模拟赛day7 数字碰撞

清北学堂模拟赛day7 数字碰撞

技术分享

技术分享

 

 

/*
clj:水题别人都满分你不是你就完了,所以说水题一定要细心一点,有这么几个细节:①前导零的处理,全是零的时候要特判②换行要注意,不要多大一行,剩下就是水水的模拟了
*/
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define ll long long
#define fo(i,l,r) for(int i = l;i <= r;i++)
#define fd(i,l,r) for(int i = r;i >= l;i--)
using namespace std;
const int maxn = 2005;
ll read(){
    ll x=0,f=1;
    char ch=getchar();
    while(!(ch>=0&&ch<=9)){if(ch==-)f=-1;ch=getchar();};
    while(ch>=0&&ch<=9){x=x*10+(ch-0);ch=getchar();};
    return x*f;
}
bool visa[maxn],visb[maxn],oka,okb;
char a[maxn],b[maxn];
int n;
int main(){
    freopen("number.in","r",stdin);
    freopen("number.out","w",stdout);
    do{
        a[++n] = getchar();
    }while(a[n]>=0&&a[n]<=9);
    n--;
    fo(i,1,n){
        b[i] = getchar();
    }
    fo(i,1,n){
        if(a[i] >= b[i]) visa[i] = true,oka = true;
        if(a[i] <= b[i]) visb[i] = true,okb = true;
    }
    bool buga = false,bugb = false;
    if(!oka) cout<<"BOOM"<<endl;
    else{
        fo(i,1,n) if(visa[i]){
            if(a[i] != 0 || i == n) buga = true;
            if(a[i] == 0 && !buga) continue;
            cout<<a[i];
        }
        cout<<endl;
    }
    
    if(!okb) cout<<"BOOM"<<endl;
    else{
        fo(i,1,n) if(visb[i]){
            if(b[i] != 0 || i == n) bugb = true;
            if(b[i] == 0 && !bugb) continue;
            cout<<b[i];
        }
    }
    return 0;
} 

 

清北学堂模拟赛day7 数字碰撞