4. +
SourceCode
public class Main {
public static void main(String[] args){
System.out.println(new java.util.Scanner(System.in).nextLine()+"2014");
}
}
8. +
SourceCode
import java.util.Scanner;
/**
* Created by nullzine on 2014/09/20.
*/
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
long n = Long.parseLong(sc.nextLine());
System.out.println(str.charAt((int)((n-1)%(long)str.length())));
}
}
16. +
SourceCode 3
dataSet = $stdin.read.split(" ").map{|m|m.to_i}
data=(dataSet[0]..dataSet[1]).to_a
a = data.select{|i|i%4==0}
b = a.select{|i|i%100==0}
c = b.select{|i|i%400==0}
p a.length-b.length+c.length
20. +
SourceCode
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String[] strs = sc.nextLine().split(" ");
int data = Integer.parseInt(strs[0]);
int n = Integer.parseInt(strs[1]);
System.out.println(new Execution(data,n).getRes());
}
}
class DataSet{
public int n;
public int diff;
public DataSet(int n,int diff){
this.n=n;
this.diff=diff;
}
}
21. +
class Execution{
private int data;;
private int n;
private ArrayList<Integer> result;
private int res;
public Execution(int data,int n){
this.data=data;
this.n=n;
if(n!=10) {
result = new ArrayList<>();
calculation();
Collections.sort(result);
res = result.get(0);
}else{
res=0;
}
}
private void calculation(){
for(int i=0;i<=data*2;i++){
if(validation(i)){
result.add(Math.abs(data-i));
}
}
}
private boolean validation(int num){
String str = Integer.toString(num);
TreeSet<Character> tmp = new TreeSet<>();
for(int i=0;i<str.length();i++){
if(!tmp.contains(str.charAt(i))){
tmp.add(str.charAt(i));
if(n<tmp.size()){
return false;
}
}
}
return true;
}
public int getRes(){
return res;
}
}