14. 22.MMaajjoorriittyyVVoottee
11)) YYEESS
public class MajorityVote {"
public static void main(String... args) {"
Random[] randoms = new Random[10];"
for (int i = 0; i < 10; i++)"
randoms[i] = new Random(System.currentTimeMillis());"
"
int count = 0;"
boolean option = randoms[0].nextBoolean();"
for (int i = 1; i < 10; i++)"
if (option == randoms[i].nextBoolean()) count++;"
"
System.out.println((count > 5)? "YES": "NO");"
}"
}"
16. 22.. 解決方法
public class MajorityVote {"
public static void main(String... args) {"
Random[] randoms = new Random[10];"
for (int i = 0; i < 10; i++)"
randoms[i] = new Random();"
"
int count = 0;"
boolean option = randoms[0].nextBoolean();"
for (int i = 1; i < 10; i++)"
if (option == randoms[i].nextBoolean()) count++;"
"
System.out.println((count > 5)? "YES": "NO");"
}"
}"
28. 44.. WWaallttzzRRhhyytthhmm
public class WaltzRhythm {"
public static void main(String... args) {"
int count = 0;"
for (int i = 0; i < Integer.MAX_VALUE; i += 3) {"
count++;"
}"
System.out.println(count);"
}"
}"
44)) それ以外 ((--771155882277888833))
31. 44.. 解決方法
public class WaltzRhythm {"
public static void main(String... args) {"
int count = 0;"
for (int i = 0; i < Integer.MAX_VALUE -3 ; i += 3) {"
count++;"
}"
System.out.println(count);"
}"
}"