HDU 4958 DP
来源:互联网 发布:国外网络流行模式 编辑:程序博客网 时间:2024/06/06 00:38
//// main.cpp// HDU 4958 DP//// Created by 郑喆君 on 8/18/14.// Copyright (c) 2014 itcast. All rights reserved.//#include <cstdlib>#include <cctype>#include <cstring>#include <cstdio>#include <cmath>#include <algorithm>#include <vector>#include <string>#include <iostream>#include <sstream>#include <map>#include <set>#include <queue>#include <stack>#include <fstream>#include <numeric>#include <iomanip>#include <bitset>#include <list>#include <stdexcept>#include <functional>#include <utility>#include <ctime>#include <cassert>#include <complex>using namespace std;typedef long long ll;typedef long double ld;const int int_max = 0x07777777;const int int_min = 0x80000000;const int inf=0x20202020;const ll mod=1000000007;const double eps=1e-9;const double pi=3.1415926535897932384626;const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}bool cmp (const void *a , const void *b ){ return *(int *)a < *(int *)b;}ld dp[1005][1005];ld fn (int a, int b) {if(a<0||b<0) return 0; else return dp[a][b];}int main(int argc, const char * argv[]){ dp[0][0] = 0; for(int i = 0; i < 1005; i++){ for(int j = 0; j < 1005-i; j++){ if(i||j){ if(i%2==0){ dp[i][j] = i+j+fn(i-1,j)*i/(i+j) + fn(i,j-1)*j/(i+j); }else{ dp[i][j] = max(fn(i-1,j),fn(i, j-1)); } } } } int t; while (scanf("%d", &t)!=EOF) { while (t--) { int n; scanf("%d", &n); int cnt = 0; for(int i = 0; i < n; i++){ int xx; scanf("%d", &xx); if(xx%2==1) cnt++; } printf("%0.f\n", (double)(dp[cnt][n-cnt]*3)); } }}
0 0
- HDU 4958 DP
- HDU DP
- DP? HDU
- DP? HDU
- DP? HDU
- 【dp】HDU
- 【dp】HDU
- 【dp】 HDU
- DP? HDU
- HDU 1003 && HDU 1231 DP
- hdu 1058 DP
- HDU 1069 dp
- HDU 1024(DP)
- hdu 1257 dp+贪心
- HDU 1087(DP)
- HDU 1506(DP)
- hdu 2844 DP 背包
- HDU 1087 简单DP
- domino服务器ID验证字过期重新验证的方法
- ios防止按钮多次点击
- openstack scheduler 配置参数说明
- java内部类总结
- Quality Settings说明
- HDU 4958 DP
- hdu 4630 No Pain No Game(树状数组离线操作)
- linux的w命令
- db2数据类型详解
- Java面向对象——封装
- 求一个数列的逆序数
- jquery阻止冒泡事件:$('span').bind("click",function(event){event.stopPropagation();})(有用源)
- WPF应用Binding之Path
- storm用于提高处理速度的并行度设计的感想2