AtCoder Beginner Contest 010をやった。
たぶんC問題解けるからのちに追加予定。
A
あだ名をどう求めるかです。
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
// Your code here!
Scanner scan = new Scanner(System.in);
System.out.println(scan.nextLine().concat("pp"));
}
}
B
いい方法ないかなーと思ったけど、実践的に考えたら「1 <= 入力値 <= 9」らしいので、パターンで判定した
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
// Your code here!
Scanner scan = new Scanner(System.in);
int[] num = new int[scan.nextInt()];
for(int i = 0; i < num.length; i++){
num[i] = scan.nextInt();
}
int cnt = 0;
for(int i = 0; i < num.length; i++){
if(num[i] == 2 || num[i] == 4 || num[i] == 8){
cnt += 1;
} else if(num[i] == 5){
cnt += 2;
} else if(num[i] == 6){
cnt += 3;
}
}
System.out.println(cnt);
}
}