This was a particularly annoying question. Mainly because the answer choices don’t have an option for ‘Don’t know’. This would ofcourse make the problem much harder (comparitively) but the question allows for inputs such as 190435 which are unclassifiable. I just assumed simple input and my solution worked, so that’s that I suppose.
import java.io.PrintWriter; import java.util.Scanner; /** * * @author Sanchit M. Bhatnagar * @see http://uhunt.felix-halim.net/id/74004 * */ public class P621 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int T = sc.nextInt(); while (T > 0) { String input = sc.next(); if (input.endsWith("35")) { out.println("-"); } else if (input.startsWith("190")) { out.println("?"); } else if (input.equals("1") || input.equals("4") || input.equals("78")) { out.println("+"); } else { out.println("*"); } T--; } out.close(); sc.close(); } }