diff --git a/seong_cheol/.DS_Store b/seong_cheol/.DS_Store index e39c51b..7d1a75d 100644 Binary files a/seong_cheol/.DS_Store and b/seong_cheol/.DS_Store differ diff --git a/seong_cheol/220320~220326/22943.cpp b/seong_cheol/220320~220326/22943.cpp new file mode 100644 index 0000000..c85eb49 --- /dev/null +++ b/seong_cheol/220320~220326/22943.cpp @@ -0,0 +1,82 @@ +// +// 22943.cpp +// main +// +// Created by wi_seong on 2022/03/26. +// + +#include +#include +#include + +using namespace std; +#define ll long long +int k, m; +vector primeNum; +bool chk1[100001]; +bool chk2[100001]; +int vis[10]; + +// 에라토스테네스의 체를 이용한 소수 만들기 +void primeNumberSeive(int n) { + vector 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; +} diff --git a/seong_cheol/220320~220326/5052.cpp b/seong_cheol/220320~220326/5052.cpp new file mode 100644 index 0000000..26a779a --- /dev/null +++ b/seong_cheol/220320~220326/5052.cpp @@ -0,0 +1,35 @@ +// +// 5052.cpp +// main +// +// Created by wi_seong on 2022/03/23. +// + +#include +#include +#include + +using namespace std; +int n; +vector> 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}); + } + for(int i = 0; i < n; i++) + if(!chk) cout << "YES" << '\n'; + else cout << "NO" << '\n'; + } + + return 0; +} diff --git a/seong_cheol/SJAlgorithm.xcodeproj/project.pbxproj b/seong_cheol/SJAlgorithm.xcodeproj/project.pbxproj index 5d8fded..b1654d8 100644 --- a/seong_cheol/SJAlgorithm.xcodeproj/project.pbxproj +++ b/seong_cheol/SJAlgorithm.xcodeproj/project.pbxproj @@ -27,6 +27,10 @@ 4D335F8827E75C7E007640F7 /* 5624.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 5624.cpp; sourceTree = ""; }; 4D335F8927E75C7E007640F7 /* 20154.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 20154.cpp; sourceTree = ""; }; 4D335F8A27E75C7E007640F7 /* 19539.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 19539.cpp; sourceTree = ""; }; + 4D69A74227F09750003FDE33 /* 8980.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = 8980.cpp; path = ../../Greedy/8980.cpp; sourceTree = ""; }; + 4D69A74327F0975C003FDE33 /* 1978.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = 1978.cpp; path = ../../Math/1978.cpp; sourceTree = ""; }; + 4D69A74527F0B1B7003FDE33 /* 5052.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 5052.cpp; sourceTree = ""; }; + 4D69A74727F0BA4F003FDE33 /* 22943.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 22943.cpp; sourceTree = ""; }; 4D6C690E27CBAE120081F18A /* 1874.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 1874.cpp; sourceTree = ""; }; 4D6C691027CBAE290081F18A /* 17212.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 17212.cpp; sourceTree = ""; }; 4D826DA0279D8C7900459892 /* 4096.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = 4096.cpp; sourceTree = ""; }; @@ -80,6 +84,18 @@ path = "220313~220319"; sourceTree = ""; }; + 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 = ""; + }; 4D6C690D27CBAD890081F18A /* 220220~220226 */ = { isa = PBXGroup; children = ( @@ -131,6 +147,7 @@ 4D25360927D4E04600405E70 /* 220227~220305 */, 4D9811EA27DDEDD900D6740A /* 220306~220312 */, 4D335F8627E75C7E007640F7 /* 220313~220319 */, + 4D69A73F27F096D9003FDE33 /* 220320~220326 */, 4DE42969279D8966007BAA4E /* Products */, ); sourceTree = ""; diff --git a/seong_cheol/SJAlgorithm.xcodeproj/project.xcworkspace/xcuserdata/wi_seong.xcuserdatad/UserInterfaceState.xcuserstate b/seong_cheol/SJAlgorithm.xcodeproj/project.xcworkspace/xcuserdata/wi_seong.xcuserdatad/UserInterfaceState.xcuserstate index 2ea22dd..72e914e 100644 Binary files a/seong_cheol/SJAlgorithm.xcodeproj/project.xcworkspace/xcuserdata/wi_seong.xcuserdatad/UserInterfaceState.xcuserstate and b/seong_cheol/SJAlgorithm.xcodeproj/project.xcworkspace/xcuserdata/wi_seong.xcuserdatad/UserInterfaceState.xcuserstate differ