It's the year 4527 and the tanks game that we all know and love still exists. There also exists Grea
来源:互联网 发布:mac中如何新建文件夹 编辑:程序博客网 时间:2024/06/06 20:54
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 aiwithout 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
35 10 1
50
41 1 10 11
110
50 3 1 100 1
0
Hint
In sample 1 numbers 10 and 1 are beautiful, number 5 is not not.
In sample 2 number 11 is not beautiful (contains two '1's), all others are beautiful.
In sample 3 number 3 is not beautiful, all others are beautiful.
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int pow(string fu);
int main()
{
int n, i, num;
int flag=1 ,fuk=1;
string fu, zi;
int sum=0;
cin>>n;
for(i=0; i<n; i++)
{
cin>>fu;
if(fu == "0")
fuk = 0;
num = pow(fu);
if(num == -1) { zi = fu; flag=0;}
if(num >=0) sum += num;
}
if(flag) zi = "1"; ///考虑全是1的情况;
if(fuk == 0) cout<<0<<endl;
else
{
cout<<zi;
for(i=0; i<sum; i++) cout<<0;
cout<<endl;
}
}
int pow(string fu)
{
int one=0, zero=0;
int i;
for(i=0; i<fu.size(); i++)
{
if(fu[i] != '0' && fu[i] != '1') return -1;
if(fu[i] == '1') one++;
if(one>1) return -1;
if(fu[i] == '0') zero++;
}
return zero;
}
- It's the year 4527 and the tanks game that we all know and love still exists. There also exists Grea
- Error reading from file ... .msi Verify that the file exists and that you ...
- Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
- Cannot write to snapshot prefix '***'. Make sure that the directory exists and is writeable解决方法
- this install package could not be opened. verify that the package exists and that you can ac
- it has a DefiningQuery and no <InsertFunction> element exists in the <ModificationFunctionMapping>
- EXISTS and NOT EXISTS
- Chanel iPhone 6 Cases the fact is that there exists a unique respected established
- it has a DefiningQuery and no InsertFunction element exists in the ModificationFunctionMapping element to support the current op
- T-CODE that exists in the SAP
- Understand the difference between IN and EXISTS in subqueries
- The difference between EXISTS and IN upon Oracle
- The problems were related to the component side and also to the client that uses the component
- oracle exists and not exists
- Please make sure the -vm option in eclipse.ini is pointing to a JDK and verify that Installed JRE’s are also using JDK installs
- Today is a gift , that's why we call it the present!
- Please make sure you have the correct access rights and the repository exists
- Please make sure you have the correct access rights and the repository exists.解决方法
- 康康准备了 M 斤的食物, 准备跟舍长交换哲学之宝 ♂
- javascript中defer的作用
- 数据库事务的四个基本性质(ACID)?
- While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was n
- Nginx 在 Windows 平台上编译
- It's the year 4527 and the tanks game that we all know and love still exists. There also exists Grea
- 辨异 —— 字母相近、含义差别很大的词组
- NSView转换为NSimage 与 UIImage转换为UIimage 总结
- js 手机端滑动分页SPager 基本示例
- windows 7系统安装与配置Tomcat服务器环境
- Android 获取栈顶activity并在service 中弹出全局dialog解决方法
- java接口和抽象类
- 反射所有方法测试终极版
- iOS开发UI篇-UIView的生命周期