File tree Expand file tree Collapse file tree 1 file changed +35
-4
lines changed Expand file tree Collapse file tree 1 file changed +35
-4
lines changed Original file line number Diff line number Diff line change 1
- // Authored by : BaaaaaaaaaaarkingDog
1
+ // Authored by : scsc3204
2
2
// Co-authored by : -
3
- // http://boj.kr/****************
3
+ // http://boj.kr/80f22c73a04a4c16a1ddf8fa5ca95ce2
4
4
#include < bits/stdc++.h>
5
5
using namespace std ;
6
6
7
- int main (void ){
7
+ int ans[102 ];
8
+ bool isopen[102 ];
9
+
10
+ void open (int n) {
11
+ for (int i = 1 ; i * n <= 100 ; i++)
12
+ isopen[i * n] = !isopen[i * n];
13
+
14
+ for (int i = 1 ; i <= n; i++)
15
+ if (isopen[i]) ans[n]++;
16
+ }
17
+
18
+ int main () {
8
19
ios::sync_with_stdio (0 );
9
20
cin.tie (0 );
21
+
22
+ // for n = 1
23
+ fill (isopen, isopen + 101 , 1 );
24
+
25
+ for (int i = 2 ; i <= 100 ; i++)
26
+ open (i);
10
27
11
- }
28
+ int t; cin >> t;
29
+ while (t--) {
30
+ int x; cin >> x;
31
+ cout << ans[x] << ' \n ' ;
32
+ }
33
+ }
34
+ /*
35
+ n번째 라운드에 대해 오픈을 수행한 뒤
36
+ 1번방부터 n번방까지 확인하며 ans[n]배열에 기록합니다.
37
+
38
+ 이 과정을 1부터 100까지 수행한 뒤
39
+ 테스트케이스 입력값에 해당하는 정답을 출력합니다.
40
+
41
+ 이 풀이와 별개로 이 문제에 관한 재미있는(?) 수학적인 성질이 있어서 다른 사람 풀이도 한 번 확인해보는걸 추천드립니다.
42
+ */
You can’t perform that action at this time.
0 commit comments