Codeforces Round #339 (Div. 2) B. Gena's Code 水题
B. Gena's Code
题目连接:
http://www.codeforces.com/contest/614/problem/B
Description
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, find their product. If it is turns to be too large, then the servers might have not enough time to assign tanks into teams and the whole game will collapse!
There are exactly n distinct countries in the world and the i-th country added ai tanks to the game. As the developers of the game are perfectionists, the number of tanks from each country is beautiful. A beautiful number, according to the developers, is such number that its decimal representation consists only of digits '1' and '0', moreover it contains at most one digit '1'. However, due to complaints from players, some number of tanks of one country was removed from the game, hence the number of tanks of this country may not remain beautiful.
Your task is to write the program that solves exactly the same problem in order to verify Gena's code correctness. Just in case.
Input
The first line of the input contains the number of countries n (1 ≤ n ≤ 100 000). The second line contains n non-negative integers ai without leading zeroes — the number of tanks of the i-th country.
It is guaranteed that the second line contains at least n - 1 beautiful numbers and the total length of all these number's representations doesn't exceed 100 000.
Output
Print a single number without leading zeroes — the product of the number of tanks presented by each country.
Sample Input
3
5 10 1
Sample Output
50
Hint
题意
给你n个数,让你输出他们的乘积
保证里面最多只有一个数不是美丽数
美丽数定义:这个数在10进制下,只含有0和1,并且最多只有一个1
题解:
如果其中有0,那么答案肯定是0
首先我们找到不是美丽数的那个数num,那么答案肯定是num*10^k
这个k就是每一个美丽数的0的个数的和就好了
代码
#include<bits/stdc++.h>
using namespace std;
string s;
string ans;
string tmp;
int num = 0;
int main()
{
int n;
scanf("%d",&n);
int flag = 0;
for(int i=0;i<n;i++)
{
cin>>tmp;
if(tmp=="0")
{
cout<<"0"<<endl;
return 0;
}
int cnt = 0;
int flag = 0;
for(int j=0;j<tmp.size();j++)
{
if(tmp[j]=='1')
cnt++;
if(tmp[j]!='1'&&tmp[j]!='0')
flag = 1;
}
if(flag||cnt>1)
ans = tmp;
else
num += tmp.size()-1;
}
if(ans.size())
cout<<ans;
else
cout<<"1";
for(int i=0;i<num;i++)
cout<<"0";
cout<<endl;
}
Codeforces Round #339 (Div. 2) B. Gena's Code 水题的更多相关文章
- Codeforces Round #339 Div.2 B - Gena's Code
It's the year 4527 and the tanks game that we all know and love still exists. There also exists Grea ...
- Codeforces Round #339 (Div. 2) A. Link/Cut Tree 水题
A. Link/Cut Tree 题目连接: http://www.codeforces.com/contest/614/problem/A Description Programmer Rostis ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos 水题
A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...
- Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题
A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...
- Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题
A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...
随机推荐
- 锁之“重量级锁”Synchronized
一.Synchronized的基本使用 Synchronized是Java中解决并发问题的一种最常用的方法,也是最简单的一种方法.Synchronized的作用主要有三个:(1)确保线程互斥的访问同步 ...
- LoadRunner error -27728
错误现象1:Action.c(16): Error -27728: Step download timeout (120 seconds) has expired whendownloading no ...
- Microsoft Office 2010 requires 的 MSXML 版本 6.10.1129.0 be 已安装在您计算机的安装"的基于 Windows 7 的计算机上安装 Office 2010 时出现错误消息
https://support.microsoft.com/zh-cn/kb/2290714
- JavaScript对象(窗口对象 定时器对象 )
1:窗口时间 confirm(str):确认对话框,确认返回trun,取消返回false,但是必须要有两个return:不然就算按下取消也会提交 第一个return:用于保证确认按钮运行 <sc ...
- 大数据处理-bitmap是个神马东西
1. Bit Map算法简介 所谓的Bit-map就是用一个bit位来标记某个元素对应的Value, 而Key即是该元素.由于采用了Bit为单位来存储数据,因此在存储空间方面,可以大大节省. 2. B ...
- 求职基础复习之冒泡排序c++版
代码中在第一层循环中增加一个bool值,是为了防止在排序完成后还继续无谓的比较,最多会有(n-1)*(n-2)/2次循环. #include<iostream> using namespa ...
- Hadoop-- MapReduce简单理解
1.Hadoop和MapReduce概念 Mapreduce是一种模式. Hadoop是一种框架. Hadoop是一个实现了mapreduce模式的开源的分布式并行编程框架. 2.Hadoop框架 ...
- VS常用技巧
VS2005代码编辑器的展开和折叠代码确实很方便和实用.以下是展开代码和折叠代码所用到的快捷键,很常用: Ctrl + M + O: 折叠所有方法 Ctrl + M + M: 折叠或者展开当前方法 C ...
- 文本框的onchange事件,如何兼容各大浏览器
在项目中经常会遇到对用户输入的数据进行实时校验,而不是等文本框失去焦点或用户手动点击校验. 首先分析下在哪些情况下文本框会产生change事件. 1.用户通过键盘入正常字符时: 2.用户通过键盘输入非 ...
- Tcl之group arguments
1 doubel quotes This allows substitutions to occur within the quotations - or "interpolation&qu ...