Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified seong_cheol/.DS_Store
Binary file not shown.
82 changes: 82 additions & 0 deletions seong_cheol/220320~220326/22943.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// 22943.cpp
// main
//
// Created by wi_seong on 2022/03/26.
//

#include <iostream>
#include <cmath>
#include <vector>

using namespace std;
#define ll long long
int k, m;
vector<ll> primeNum;
bool chk1[100001];
bool chk2[100001];
int vis[10];

// 에라토스테네스의 체를 이용한 소수 만들기
void primeNumberSeive(int n) {
vector<bool> isPrime(n + 1);
for(int i = 2; i <= sqrt(n); i++) {
if(isPrime[i]) continue;
for(int j = i * i; j <= n; j += i)
isPrime[j] = true;
}
for(int i = 2; i <= n; i++)
if(!isPrime[i]) primeNum.push_back(i);
}

bool check2(int val) {
while(val % m ==0)
val /= m;
if(chk2[val] == 1)
return true;
return false;
}

int comb(int cur, int idx, int max, int val) {
if(idx == max) {
if(chk1[val] == 1 && check2(val))
return 1;
return 0;
}
int ret = 0;
for(int i = cur; i <= 9; i++) {
if(idx ==0 && i == 0)
continue;
if(vis[i] == 1)
continue;
vis[i] = 1;
ret += comb(cur, idx + 1, max, val * 10 + i);
vis[i] = 0;
}

return ret;
}

int main() {
ios::sync_with_stdio(0);
cin.tie(0);

cin >> k >> m;
primeNumberSeive(m);

int primeSize = int(primeNum.size());
for(int i = 0; i < primeSize; i++) {
for(int j = i + 1; j < primeSize; j++) {
if(primeNum[i] + primeNum[j] < 100000)
chk1[primeNum[i] + primeNum[j]] = 1;
}
for(int j = i; j < primeSize; j++) {
if(primeNum[i] + primeNum[j] < 100000)
chk2[primeNum[i] * primeNum[j]] = 1;
}
}
int ans = comb(0, 0, 1, 0);
cout << ans;

return 0;
}
35 changes: 35 additions & 0 deletions seong_cheol/220320~220326/5052.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// 5052.cpp
// main
//
// Created by wi_seong on 2022/03/23.
//

#include <iostream>
#include <string>
#include <vector>

using namespace std;
int n;
vector<pair<int, string>> v;

int main() {
ios::sync_with_stdio(0);
cin.tie(0);

int t; cin >> t;
while(t--) {
cin >> n;
bool chk = false;
for(int i = 0; i < n; i++) {
string s; cin >> s;
int len = int(s.length());
v.push_back({len, s});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다시 생각호고
Trie 공부하고 적용해보셈

}
for(int i = 0; i < n; i++)
if(!chk) cout << "YES" << '\n';
else cout << "NO" << '\n';
}

return 0;
}
17 changes: 17 additions & 0 deletions seong_cheol/SJAlgorithm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
4D335F8827E75C7E007640F7 /* 5624.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 5624.cpp; sourceTree = "<group>"; };
4D335F8927E75C7E007640F7 /* 20154.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 20154.cpp; sourceTree = "<group>"; };
4D335F8A27E75C7E007640F7 /* 19539.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 19539.cpp; sourceTree = "<group>"; };
4D69A74227F09750003FDE33 /* 8980.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = 8980.cpp; path = ../../Greedy/8980.cpp; sourceTree = "<group>"; };
4D69A74327F0975C003FDE33 /* 1978.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = 1978.cpp; path = ../../Math/1978.cpp; sourceTree = "<group>"; };
4D69A74527F0B1B7003FDE33 /* 5052.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 5052.cpp; sourceTree = "<group>"; };
4D69A74727F0BA4F003FDE33 /* 22943.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 22943.cpp; sourceTree = "<group>"; };
4D6C690E27CBAE120081F18A /* 1874.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 1874.cpp; sourceTree = "<group>"; };
4D6C691027CBAE290081F18A /* 17212.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 17212.cpp; sourceTree = "<group>"; };
4D826DA0279D8C7900459892 /* 4096.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 4096.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -80,6 +84,18 @@
path = "220313~220319";
sourceTree = "<group>";
};
4D69A73F27F096D9003FDE33 /* 220320~220326 */ = {
isa = PBXGroup;
children = (
4D69A74327F0975C003FDE33 /* 1978.cpp */,
4D69A74527F0B1B7003FDE33 /* 5052.cpp */,
4D69A74227F09750003FDE33 /* 8980.cpp */,
4D69A74727F0BA4F003FDE33 /* 22943.cpp */,
);
name = "220320~220326";
path = "../../../😁/알고리즘/Algorithm/Backjoon/SJAlgorithm/220320~220326";
sourceTree = "<group>";
};
4D6C690D27CBAD890081F18A /* 220220~220226 */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -131,6 +147,7 @@
4D25360927D4E04600405E70 /* 220227~220305 */,
4D9811EA27DDEDD900D6740A /* 220306~220312 */,
4D335F8627E75C7E007640F7 /* 220313~220319 */,
4D69A73F27F096D9003FDE33 /* 220320~220326 */,
4DE42969279D8966007BAA4E /* Products */,
);
sourceTree = "<group>";
Expand Down
Binary file not shown.