8000 Merge pull request #394 from neppiness/6359 · jh2ee/basic-algo-lecture@591e57f · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 591e57f

Browse files
Merge pull request encrypted-def#394 from neppiness/6359
update: 0x12 6359.cpp
2 parents 1710427 + f3d7b7e commit 591e57f

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

0x12/solutions/6359.cpp

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
1-
// Authored by : BaaaaaaaaaaarkingDog
1+
// Authored by : scsc3204
22
// Co-authored by : -
3-
// http://boj.kr/****************
3+
// http://boj.kr/80f22c73a04a4c16a1ddf8fa5ca95ce2
44
#include <bits/stdc++.h>
55
using namespace std;
66

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() {
819
ios::sync_with_stdio(0);
920
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);
1027

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+
*/

0 commit comments

Comments
 (0)
0