mport java.util.Arrays; //테스트로 출력해 보기 위한 코드입니다.
public class BestSet {
public int[] bestSet(int n, int s){
int[] answer = null;
if(n>s) {
answer = new int[1];
answer[0]=-1;
return answer;
}
answer = new int[n];
int a = s/n;
for(int i=0;i<n;i++) {
answer[i]=a;
}
for(int i=0;i<s%n;i++) {
answer[n-1-i]++;
}
return answer;
}
public static void main(String[] args) {
BestSet c = new BestSet();
//아래는 테스트로 출력해 보기 위한 코드입니다.
System.out.println(Arrays.toString(c.bestSet(3,13)));
}
}
public class Caesar { String caesar ( String s , int n ) { n %= 26 ; String result = "" ; char [] temp = s . toCharArray (); for ( int i = 0 ; i < temp . length ; i ++) { if ( temp [ i ]>= 'a' && temp [ i ]<= 'z' ) temp [ i ] = ( char ) (( temp [ i ]+ n )> 'z' ? ( temp [ i ]+ n - 1 )% 'z' + 'a' : ( temp [ i ]+ n )); else if ( temp [ i ]>= 'A' && temp [ i ]<= 'Z' ) temp [ i ] = ( char ) (( temp [ i ]+ n )> 'Z' ? ( temp [ i ]+ n - 1 )% 'Z' + 'A' : ( temp [ i ]+ n )); result += temp [ i ]; } return result ; } public static void main ( String [] args ) { Caesar c = new Caesar (); System . out . println ( "s는 'a B z', n은 4인 경우: " + c . caesar ( ...
댓글
댓글 쓰기