Codeforces Round #341 (Div. 2)
2016-02-01 11:34
246 查看
http://codeforces.com/contest/621
A. Wet Shark and Odd and Even
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Sample test(s)
input
output
input
output
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
题目很简单,判断一下奇数的个数就好了,如果奇数的个数为奇数,那么就找一个最小小的奇数去掉。还有一些细节问题
View Code
A. Wet Shark and Odd and Even
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark.
Note, that if Wet Shark uses no integers from the n integers, the sum is an even integer 0.
Input
The first line of the input contains one integer, n (1 ≤ n ≤ 100 000). The next line contains n space separated integers given to Wet Shark. Each of these integers is in range from 1 to 109, inclusive.
Output
Print the maximum possible even sum that can be obtained if we use some of the given integers.
Sample test(s)
input
3 1 2 3
output
6
input
5 999999999 999999999 999999999 999999999 999999999
output
3999999996
Note
In the first sample, we can simply take all three integers for a total sum of 6.
In the second sample Wet Shark should take any four out of five integers 999 999 999.
题目很简单,判断一下奇数的个数就好了,如果奇数的个数为奇数,那么就找一个最小小的奇数去掉。还有一些细节问题
/* *********************************************** Author : Created Time :2016/2/1 10:23:27 File Name :cf341c.cpp ************************************************ */ #include <iostream> #include <cstring> #include <cstdlib> #include <stdio.h> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <math.h> #include <stdlib.h> #include <iomanip> #include <list> #include <deque> #include <stack> #define ull unsigned long long #define ll long long #define mod 90001 #define INF 0x3f3f3f3f #define maxn 100000+10 #define cle(a) memset(a,0,sizeof(a)) const ull inf = 1LL << 61; const double eps=1e-5; using namespace std; bool cmp(int a,int b){ return a>b; } int l[maxn],r[maxn]; int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif //freopen("out.txt","w",stdout); int n,p; while(cin>>n>>p){ for(int i=0;i<n;i++){ cin>>l[i]>>r[i]; } l =l[0]; r =r[0]; double sum=0; for(int i=0;i<n;i++){ double x=((r[i]-l[i]+1)-((r[i]-l[i]+1)/p)*1.0)/(r[i]-l[i]+1); double y=((r[i+1]-l[i+1]+1)-((r[i+1]-l[i+1]+1)/p)*1.0)/(r[i+1]-l[i+1]+1); sum+=(1-x*y)*2000; } printf("%.10lf\n",sum); } return 0; }
View Code
相关文章推荐
- Oracle 笔记
- 设计模式之禅之设计模式-桥梁模式
- Unity3D 内存 释放
- android studio编译android M时无法使用org.apache.http.**的解决方法
- 将命令加入linux的环境变量
- 梦中的草原,无垠的天地
- jQuery Easing 使用方法及其图解
- DUBBO本地搭建及小案例
- 【高效server实践】--协议先行
- 关于umask及相关权限知识的整理
- 苹果开发者购买失败
- python 模块(module)基础讲解
- 金融信息交换协议(FIX)5.0 FIXT1.1(5)
- 《人性的弱点》总结之一 --- 人际交往的基本技巧
- django_cms安装技巧
- iOS 如何改变表视图分割线在iOS7中的默认偏移
- java使用dom4j读取xml的简单例子
- 冬林趣语
- spark调优
- 几种常见的载入中、loading页面效果的实现方法总结