标签:des style blog http color io os ar java
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 401 Accepted Submission(s): 149
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<functional> 5 #include<iostream> 6 using namespace std; 7 int str[120]; 8 int main() 9 { 10 int n,i,res; 11 while(scanf("%d",&n)!=EOF) 12 { 13 res=10; 14 for(i=0;i<n;i++) 15 { 16 scanf("%d",&str[i]); 17 if(str[i]&1==1&&res>str[i]) 18 res=str[i]; 19 } 20 if(res==10){ 21 printf("-1\n"); 22 continue; 23 } 24 sort(str,str+n,greater<int>()); 25 int fir=-1,st=res; 26 for(i=0;i<n;i++) 27 { 28 if(res==str[i]) res=-1; 29 else 30 { 31 fir=str[i]; 32 break; 33 } 34 } 35 if(fir==0) printf("-1\n"); 36 else 37 { 38 if(fir!=-1) 39 printf("%d",fir); 40 for( i++; i<n;i++) 41 if(res==str[i])res=-1; 42 else 43 printf("%d",str[i]); 44 printf("%d\n",st); 45 } 46 } 47 return 0; 48 }
hdu----(5055)Bob and math problem(贪心)
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/gongxijun/p/3999289.html