CodeForces 614B Gena's Code

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int flag;
char s[100000+10];
int zero;
char q[100000+10];

bool Perfect()
{
    int len=strlen(s);
    for(int i=1; i<len; i++)
        if(s[i]!='0') return 0;
    if(s[0]!='1') return 0;
    return 1;
}

int main()
{
    flag=1;
    zero=0;
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%s",s);
        if(strcmp("0",s)==0) flag=0;
        else if(Perfect())
        {
            zero+=strlen(s)-1;
        }
        else strcpy(q,s);
    }
    if(flag==0) printf("0
");
    else
    {
        if(q[0]==0) printf("1");
        else printf("%s",q);
        for(int i=0; i<zero; i++) printf("0");
        printf("
");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/zufezzt/p/5141839.html