HDU 5055 Bob and math problem
来源:互联网 发布:表情包走红网络论文 编辑:程序博客网 时间:2024/05/17 04:38
简单贪心
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int maxm=105;const int inf=101;int a[maxm];int main(){ int n; while(scanf("%d",&n)!=EOF) { int MIN=inf,w,i,temp,ok=0; for(int i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]%2==1) { ok=1; MIN=min(MIN,a[i]); } } if(!ok) { printf("-1\n"); continue; } sort(a,a+n); for(int i=0;i<n;i++) { if(MIN==a[i]) { w=i; break; } } int OK=1; int cnt=0; for(int i=n-1;i>=0;i--) { if(i!=w) { cnt++; if(cnt==1&&a[i]==0) { OK=0; break; } else { printf("%d",a[i]); } } } if(OK) { printf("%d\n",a[w]); } else { printf("-1\n"); } } return 0;}
0 0
- HDU 5055 Bob and math problem
- hdu 5055 Bob and math problem
- HDU 5055 Bob and math problem
- [5055]Bob and math problem(hdu)
- hdu--5055 Bob and math problem
- HDU 5055 Bob and math problem 数学题
- hdu 5055 Bob and math problem
- HDU 5055 Bob and math problem
- HDU 5055Bob and math problem(构造)
- HDU 5055 Bob and math problem
- HDU 5055 - Bob and math problem(贪心)
- HDU —— 5055 Bob and math problem
- HDU 5055 Bob and math problem(构造)
- HDU-#5055 Bob and math problem(模拟)
- hdu 5055 Bob and math problem(模拟)
- 【BestCoder】 HDOJ 5055 Bob and math problem
- HDOJ 5055 Bob and math problem
- HDU 5055 Bob and math problem(贪心)——BestCoder Round #11(div.2)
- 设计模式(3)- 状态设计模式State
- JQuery 对 Select option 的操作
- Java编程规范
- ASP.NET MVC框架下使用MVVM模式
- iOS学习之升级Xcode之后VVDocumenter-Xcode不能用解决办法
- HDU 5055 Bob and math problem
- Opencv2.4.9源码分析——HoughLinesP
- 360详解儿童手表背后技术:五颗芯片共同定位
- 500 (Internal Server Error)错误解析
- 利用CocoaHttpServer搭建手机本地服务器
- Masonry的使用和介绍
- js 自动补全
- 9.打开MIUI中的悬浮窗权限编辑界面分析过程
- Android smail变量对照表