04.01
1 2 3 4 5 6 |
public class Program { public static Boolean Puzzle(Boolean x, Boolean y) { Boolean ans=x|y; return ans; } } |
04.02
1 2 3 4 5 6 |
public class Program { public static Boolean Puzzle(Boolean x, Boolean y) { Boolean ans=x&&y; return ans; } } |
04.03
1 2 3 4 5 |
public class Program { public static Boolean Puzzle(int x) { return x<50; } } |
04.04
1 2 3 4 5 |
public class Program { public static Boolean Puzzle(int x, int y) { return x<y; } } |
04.05
写if语句多的话不给三星QAQ
1 2 3 4 5 6 |
public class Program { public static int Puzzle(int i) { return i==0?0:Math.abs(i)/i; } } |
04.06
1 2 3 4 5 6 |
public class Program { public static Boolean Puzzle(int i, int j) { return false; } } |
04.07
1 2 3 4 5 6 |
public class Program { public static int Puzzle(int i) { if(i>=100) return 3; else return 2; } } |
04.08
1 2 3 4 5 6 |
public class Program { public static String Puzzle(int i) { if(i%2==1) return "odd"; else return "even"; } } |
04.09
1 2 3 4 5 6 |
public class Program { public static String Puzzle(int i) { if(i%5==0) return "multiple of 5"; else return "not a multiple of 5"; } } |
04.10
1 2 3 4 5 6 7 |
public class Program { public static String Puzzle(int i, int x) { if(i%x==0) return "multiple of " + x; else return "not a multiple of "+x; } } |
04.11
1 2 3 4 5 6 |
public class Program { public static String Puzzle(int i, int j, int k) { if(i/(double)j==j/(double)k&&(j!=k)&&(i!=j)) return "yes!"; return "no"; } } |
04.12
1 2 3 4 5 6 7 |
public class Program { public static int Puzzle(int i) { if(i<=7) return 0; if(i<=14) return 7; else return 21; } } |
05.01
还是如果if判断条件多的话,不给三星,所以比赛的时候注意一下。
1 2 3 4 5 6 |
public class Program { public static String Puzzle(String s) { int len=s.length(); return len<4 ? "short":len<8?"average":len<15?"long":"super long"; } } |
05.02
1 2 3 4 5 6 7 |
public class Program { public static String Puzzle(int i) { if(i%1111==0) return "fancy year"; else return "not a fancy year"; } } |
05.03
直角三角形,试了多组数据才看出来。
1 2 3 4 5 |
public class Program { public static Boolean Puzzle(int a, int b, int c) { return (a*a+b*b==c*c)||(a*a+c*c==b*b)||(b*b+c*c==a*a); } } |
05.04
1 2 3 4 5 |
public class Program { public static int Puzzle(int x, int y) { return Math.abs(x)+Math.abs(y); } } |
05.05
1 2 3 4 5 6 |
public class Program { public static Boolean Puzzle(int i, int j) { return (i*i==j)?true:false; } } |