You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int a0 = 0; a0 < t; a0++){ int n = in.nextInt(); StringBuffer sb = new StringBuffer(); if (n%3==0) { System.out.println(append(n,"5")); } else if (n%3==1) { if (n<10) { System.out.println("-1"); } else { System.out.println(append(n-10,"5") + (append(10,"3"))); } } else if (n%3==2) { if (n<5) { System.out.println("-1"); } else { System.out.println(append(n-5,"5") +(append(5,"3"))); } } } } private static String append(int numberOfTimes , String value){ StringBuffer sb = new StringBuffer(); for (int i = 0; i < numberOfTimes; i++) { sb.append(value); } return sb.toString(); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and The Beast
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}