您的位置:首页 > 其它

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
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: