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\n");
    else
    {
        if(q[0]==0) printf("1");
        else printf("%s",q);
        for(int i=0; i<zero; i++) printf("0");
        printf("\n");
    }
    return 0;
}

CodeForces 614B Gena's Code

时间: 2024-10-10 17:27:00

CodeForces 614B Gena's Code的相关文章

[CodeForces - 614B] B - Gena&#39;s Code

A - Link/Cut Tree Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the exposeprocedure. Unfortunately, Rostislav is unable to understand the definition

Codeforces Round #339 (Div. 2) B. Gena&#39;s Code

B. Gena's Code It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, f

Gena&#39;s Code

 Gena's Code It's the year 4527 and the tanks game that we all know and love still exists. There also exists Great Gena's code, written in 2016. The problem this code solves is: given the number of tanks that go into the battle from each country, fin

【Codeforces 1129C】Morse Code

Codeforces 1129 C 题意:给一个0/1串,问它的每一个前缀中的每一个子串能解析成莫尔斯电码的串的种数. 思路:首先对于这个串构造后缀自动机,那么从起点走到每一个节点的每一条路径都代表了这个串的一个子串,所以考虑以后缀自动机上的节点作为dp的对象,即\(dp(i)\)表示考虑第i个节点所表示的子串们,能够解释成多少种串. 转移方程就考虑现在在u节点,\(dp(go(u,i))\)可以加上\(dp(u)\)的值. 求答案的时候需要注意.我们需要在插入字符的时候就将每一个节点所对应的前

codeforces 614B(div.2) 模拟

模拟乘法 有毒的一题,各种细节..代码写得自己都不想看.. #include"cstdio" #include"queue" #include"cmath" #include"stack" #include"iostream" #include"algorithm" #include"cstring" #include"queue" #includ

Codeforces Round #584 - Dasha Code Championship - Elimination Round (rated, open for everyone, Div. 1 + Div. 2)

怎么老是垫底啊. 不高兴. 似乎 A 掉一道题总比别人慢一些. A. Paint the Numbers 贪心,从小到大枚举,如果没有被涂色,就新增一个颜色把自己和倍数都涂上. #include<bits/stdc++.h> #define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to) #define dbg(...) fprintf(stderr, __VA_ARGS__) #define F

Cow and Snacks(吃点心--图论转换) Codeforces Round #584 - Dasha Code Championship - Elimination Round (rated, open for everyone, Div. 1 + Div. 2)

题意:https://codeforc.es/contest/1209/problem/D 有n个点心,有k个人,每个人都有喜欢的两个点心,现在给他们排个队,一个一个吃,每个人只要有自己喜欢的点心就会吃掉(不会留给后面的人). 如果有人什么都没吃就会不开心,问怎么安排使不开心的人最少. 思路: 看成一个图的问题,点心是节点,人是一条边.对于每个连通块,总会有一个人吃两个点心,其他人吃一个(其中一个是其他人也就吃掉了的). 可以保证这样是最优的,所有每个连通块的答案是连通数 x-1. 1 #def

[Codeforces 1242B]0-1 MST

Description 题库链接 给你一张 \(n\) 个点的完全图,其中有 \(m\) 条边长度为 \(1\),其余全为 \(0\).问你这张图的最小生成树为多少. \(1\leq n\leq 100000,0 \leq m \leq \min\left(\frac{n(n-1)}{2},10^5\right)\) Solution 容易发现,答案就是补图连通块个数 \(-1\).喜闻乐见的抄板子了... 解析详见[Codeforces 920E]Connected Components? C

COdeforces#417D Cunning Gena(状压DP)

A boy named Gena really wants to get to the "Russian Code Cup" finals, or at least get a t-shirt. But the offered problems are too complex, so he made an arrangement with his n friends that they will solve the problems for him. The participants