- 배열 나열된것 보기

1
2
int[] arr = {1,2,3,4,5}
System.out.println(Arrays.toString(arr));
cs

 

-피보나치 Bottom Up에서 메모리 아끼기

ex) 12000000번째 피보나치 수열의 %333은????

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.*;
 
public class test {
 
    static int[] d = new int[3];
    public static void main(String[] args) throws Exception {
        d[0= 0;
        d[1= 1;
        
        for(int i = 2 ; i <= 12000000 ; i++) {
            d[i%3= (d[(i-1)%3+ d[(i-2)%3]) % 333;
            System.out.println(d[i%3+ " " + d[(i-1)%3+ " " + d[(i-2)%3]);
        }
        
        System.out.println(d[12000000%3]);
    }
 
}
 
cs

 

 

- nPr, nCr

알고리즘은 잘 알고있으니 PASS

 

 

- 소수 n번자리 수

1
2
3
double a = 1.21592349233;
System.out.println(String.format("%.6f", a))
 
cs

 

 

-냅색 

따로 공부하자

+ Recent posts