public class test { public void maxNum(){ int count = 0; StringBuilder zero = new StringBuilder(); Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); String str = in.nextLine(); String [] temp =str.split(" "); for(String s:temp){ if(s.equals("5")){ count++; } else zero.append('0'); } String res =""; if(count == 0) System.out.println("0"); else if(count<9||count==temp.length) System.out.println("-1"); else { for(int i=0;i<count/9;i++) res+="555555555"; System.out.println(res+zero.toString()); } } public static void main(String args[]) { test obj =new test(); obj.maxNum(); } } 我感觉我这样应该可以,不过全零的时候不应该输出0吗😂
点赞 1

相关推荐

点赞 评论 收藏
分享
码农索隆:想看offer细节
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务