zoukankan      html  css  js  c++  java
  • codeforces 614B(div.2) 模拟

    模拟乘法

    有毒的一题,各种细节。。代码写得自己都不想看。。

    #include"cstdio"
    #include"queue"
    #include"cmath"
    #include"stack"
    #include"iostream"
    #include"algorithm"
    #include"cstring"
    #include"queue"
    #include"map"
    #include"vector"
    #define ll long long
    #define mems(a,b) memset(a,b,sizeof(a))
    
    using namespace std;
    const int MAXN = 100500;
    const int MAXE = 200500;
    const int INF = 0x3f3f3f;
    char arr[MAXN],t[MAXN];
    
    int main(){
        int n;
        scanf("%d",&n);
        int has_zero=0;
        int zero=0,mark=0;
        for(int i=0;i<n;i++){
            scanf("%s",arr);
            if(has_zero) continue;
            int len=strlen(arr);
            if(arr[0]=='0'){
                cout<<'0';
                has_zero=1;
            }
            else{
                int one=0,flag=0;
                for(int j=0;j<len;j++){
                    if((arr[j]!='0'&&arr[j]!='1')||(arr[j]=='1'&&one>=1)){
                        flag=1;
                        break;
                    }
                    else if(arr[j]=='1') one++;
                }
                if(flag) {
                    for(int j=0;j<len;j++) t[j]=arr[j];
                    mark=1;
                }
                else zero+=len-1;
            }
        }
        if(has_zero) return 0;
        if(n==1){
            cout<<arr;
            return 0;
        }
    
        if(!zero&&!mark) cout<<'1';
        else{
            if(!mark) cout<<'1';
            else cout<<t;
            for(int i=0;i<zero;i++) cout<<'0';
        }
        return 0;
    }
  • 相关阅读:
    Spring面试,IoC和AOP的理解
    WEB打印(jsp版)
    Spring事务管理机制的实现原理-动态代理
    spring面试题
    oracle PLSQL基础学习
    oracle创建表空间
    WM_CONCAT字符超过4000的处理办法
    Oracle 数据泵使用详解
    Oracle 数据泵详解
    linux下启动oracle
  • 原文地址:https://www.cnblogs.com/luxiaoming/p/5134541.html
Copyright © 2011-2022 走看看