hdu5744 多校2.11
来源:互联网 发布:java培训班哪个好 编辑:程序博客网 时间:2024/05/17 13:39
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5744
题目大意:给你每个字母的数量,问能组成的回文串的集合里面最短的长度最长是多少。
思路:统计奇数个数,将其变为1,累加所有的数量,将累加和平均分配给奇数个数。。。
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <cmath>#include <stack>#include <queue>#include <algorithm>#include <vector>#include <map>#include <set>#include <stdlib.h>#include <iomanip>using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")#define maxn 100005#define MOD 1000000007#define mem(a , b) memset(a , b , sizeof(a))#define LL long long#define ULL unsigned long long#define FOR(i , n) for(int i = 1 ; i<= n ; i ++)typedef pair<int , int> pii;//priority_queue<int , vector<int> , greater<int> > Q;int t , n , q;int a[maxn] , b[maxn];int main(){ scanf("%d" , &t); while(t--) { scanf("%d" , &n); int id1 = 0 , id2 = 0 , tmp; int sum1 = 0 , sum2 = 0; for(int i = 1 ; i <= n ; i ++) { scanf("%d" , &tmp); if(tmp%2) sum1 ++ , sum2 --; sum2 += tmp; } if(sum1) tmp = sum2 / sum1; else tmp = sum2; if(tmp % 2 && sum1) tmp --; if(sum1) tmp += 1; printf("%d\n" , tmp); } return 0;}
0 0
- hdu5744 多校2.11
- HDU5744(贪心)
- HDU5744 Keep On Movin
- hdu5744简单模拟
- HDU5744 Keep On Movin(贪心)
- hdu5744 Keep On Movin(水)
- hdu5744(16多校第2场,思维题)
- (多校第二场1011)HDU5744 Keep On Movin
- hdu5744——Keep On Movin(构造回文)
- 【HDU5744 2016 Multi-University Training Contest 2K】【水题 贪心】Keep On Movin 给定字符使得最短回文串最长
- 2.11
- 多校
- 多校
- 多校
- 2.11 mood
- 习题2.11
- 【例 2.11】
- 2.11-逻辑运算
- nodejs与Sublime相结合
- 根据图片名字获取Drawable对象
- c++内存分配陷阱
- MySql 按记录查询使用distinct去重的小技巧
- 百度ueditor图片上传提示“上传失败,请重试”解决办法
- hdu5744 多校2.11
- Spark算子:RDD行动Action操作(3)–aggregate、fold、lookup
- 有益的评论搜集
- android MVVM开发模式(一)
- mysql orderby limit 翻页数据重复的问题
- 主线程阻塞、消息队列机制和图片下载
- java学习之学习GUI建议
- JAVA生成短8位UUID(未测试)
- 软件优才夏令营A decentralized approach for mining event correlations in distributed system monitoring译文(原创)