본문 바로가기
알고리즘/DP

6359 만취한 상범

by tryotto 2019. 7. 6.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
 
int check[105];
 
int main() {
    int t;
    scanf("%d"&t);
 
    while (t--) {
        int n;
        scanf("%d"&n);
 
        for (int i = 1; i <= n; i++)
            check[i] = 1;
 
        for (int i = 1; i <= n; i++) {
            for (int j = 1; i * j <= n; j++) {
                check[i * j] *= (-1);
            }
        }
 
        int rst = 0;
        for (int i = 1; i <= n; i++) {
            if (check[i] == -1)
                rst++;
        }            
        printf("%d\n", rst);
    }
}
cs


'알고리즘 > DP' 카테고리의 다른 글

2293 동전1  (0) 2019.07.06
11048 이동하기  (0) 2019.07.06
9507 Generations of Tribbles  (0) 2019.07.06
2698 인접한 비트의 갯수  (0) 2019.07.06
11726 2*n 타일링  (0) 2019.07.06