HDU 2006 (水)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2006
题目大意:给你几个数,求奇数的乘积和
解题思路:
很水,不需要数组的,一个变量 x 就行
代码:
#include<iostream>
using namespace std;
int main()
{
int sum;
int n;
int a[];
while(cin >> n)
{
sum = ;
for(int i = ; i < n; i ++)
{
cin >> a[i];
if(a[i] % != )
sum *= a[i];
}
cout << sum << endl; }
}
优化:
#include<iostream>
using namespace std;
int main()
{
int sum;
int n;
int x;
while(cin >> n)
{
sum = ;
for(int i = ; i < n; i ++)
{
cin >> x;
if(x % != )
sum *=x;
}
cout << sum << endl; }
}
HDU 2006 (水)的更多相关文章
- HDU-1042-N!(Java大法好 && HDU大数水题)
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- hdu 4464 水
http://acm.hdu.edu.cn/showproblem.php?pid=4464 现场赛总会有水题,这就是最水的一道,预计也就是能当高校的上机题,保研用,呵呵~~~ #include &l ...
- HDU 2006 求奇数的乘积
http://acm.hdu.edu.cn/showproblem.php?pid=2006 Problem Description 给你n个整数,求他们中所有奇数的乘积. Input 输入数据包 ...
- HDU 5391 水题。
E - 5 Time Limit:1500MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- hdu 1544 水题
水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...
- hdu 3357 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...
- hdu 5007 水 弦
http://acm.hdu.edu.cn/showproblem.php?pid=5007 纯粹的联系String的substr 什么时候substr拦截比写短话 string te; int n; ...
- Tickets HDU - 1260 水DP
HDU - 1260 现在有n个人要买电影票,如果知道每个人单独买票花费的时间, 还有和前一个人一起买花费的时间,问最少花多长时间可以全部买完票. 直接dp就行,注意下输出和初始化 每次从dp[i-1 ...
- HDU排序水题
1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...
随机推荐
- 使用 Junit + Mockito 实践单元测试
一.前言 相信做过开发的同学,都多多少少写过下面的代码,很长一段时间我一直以为这就是单元测试... @SpringBootTest @RunWith(SpringRunner.class) publi ...
- css之单位
css之单位 角度<angle> 用于<gradient>s和某些transform功能中 deg表示以度为单位的角度.一整圈就是360deg. 例如:0deg,90deg,1 ...
- 【Linux常见命令】ls命令
ls - list directory contents ls命令用于显示指定工作目录下之内容(列出目前工作目录所含之文件及子目录). 语法: ls [OPTION]... [FILE]... l ...
- Python抓取新浪新闻数据(二)
以下是抓取的完整代码(抓取了网页的title,newssource,dt,article,editor,comments)举例: 转载于:https://blog.51cto.com/2290153/ ...
- MySQL重新初始化安装数据库
删除./mysql/var下的所有数据后,怎么重新安装初始数据库? (1)进入./mysql/bin目录下,执行脚本./mysql_install_db: (2)执行完(1)后,此时会在./mysq ...
- 解决vue中BMap未定义问题
原文链接: 点我 最近在项目中使用了百度地图来显示物流信息,实现方式有两种: 引用Vue Baidu Map引用BMap存在的问题:\color{red}{存在的问题:}存在的问题::使用BMap可以 ...
- 数学--数论--HDU 1299 +POJ 2917 Diophantus of Alexandria (因子个数函数+公式推导)
Diophantus of Alexandria was an egypt mathematician living in Alexandria. He was one of the first ma ...
- UTC 时间转化为北京时间
// UTC 时间转化为北京时间 function utc2beijing(utcTime) { var T_pos = utcTime.indexOf('T'); var Z_pos = utcTi ...
- Java中常用的获取从当前月开始的前第i个月、取结束时间与开始时间相差多少个月份等的方法
@RunWith(SpringRunner.class) @SpringBootTest public class DateTest { @Test public void test(){ DateF ...
- 说一说Web开发中两种常用的分层架构及其对应的代码模型
昨天妹子让我帮她解决个问题,本以为可以轻松搞定,但是打开他们项目的一瞬间,我头皮发麻.本身功能不多的一个小项目,解决方案里竟然有几十个类库.仅仅搞明白各个类库的作用,代码层次之间的引用关系就花了一个多 ...