JAVA 题有点问题,常规写过不了,要多加一个while,可能是例子为一组,后台测试要输入很多组。
import java.util.HashMap;
import java.util.Scanner;
import java.util.LinkedList;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = Integer.valueOf(sc.nextLine());
for (int i = 0; i <n; i++){
String str = sc.nextLine();
helper(str);
}
}
}
private static void helper(String s){
if (s == null) return;
int a = 0;
if (s.length() % 8 != 0) a = 8 - s.length()%8;
while(a>0) {
s += "0";
a--;
}
/*
int a = s.length() % 8;
StringBuilder sb = new StringBuilder(s);
if(a != 0){
for(int i = 8-a ; i > 0 ; i--){
sb.append('0');
}
}
s = sb.toString();
*/
for (int i = 0; i < s.length(); i+=8){
System.out.println(s.substring(i, i+8));
}
}
}