-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <iostream> | ||
#include <algorithm> | ||
#include <vector> | ||
|
||
using namespace std; | ||
|
||
vector<char> random (int n, int k) { | ||
vector<char> v(n, '?'); //처음 가르킨 곳이 v[0] 알파벳 | ||
int cnt; | ||
int order = 0; | ||
char input; | ||
|
||
for(int i=0; i<k; i++) { | ||
cin >> cnt >> input; | ||
order += cnt; | ||
|
||
order %= n; | ||
// 해당 위치가 비었거나 같은 알파벳인 경우 | ||
if (v[order] == '?' || v[order] == input) { | ||
v[order] = input; | ||
} | ||
// 해당 위치에 다른 알파벳이 있는 경우(행운의 바퀴x) | ||
else { | ||
v[0] = '!'; | ||
return v; | ||
} | ||
} | ||
//같은 애 있나 확인 | ||
for(int i=0; i<n-1; i++) { | ||
for(int j=i+1; j<n; j++) { | ||
if(v[i] != '?' && v[i] == v[j]) { | ||
v[0] = '!'; | ||
return v; | ||
} | ||
} | ||
} | ||
|
||
// 벡터 회전시키기 | ||
reverse(v.begin(), v.end()); | ||
rotate(v.begin(), v.end() - order -1, v.end()); | ||
return v; | ||
} | ||
|
||
|
||
int main() { | ||
int n, k; | ||
cin >> n >> k; | ||
|
||
vector<char> result; | ||
result = random(n, k); | ||
|
||
if(result[0] == '!'){ | ||
cout << '!'; | ||
} | ||
else { | ||
for(char ch : result) { | ||
cout << ch; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <iostream> | ||
#include <algorithm> | ||
#include <vector> | ||
|
||
/* | ||
b - a가 가장 큰 경우가 언제일지 잘 생각해보아요! | ||
n = a + b를 만족시키는 두 소수들을 어디서부터 탐색하면 좋을까요? | ||
*/ | ||
using namespace std; | ||
|
||
int getPrime() { | ||
|
||
} | ||
|
||
|
||
int main() { | ||
|
||
int input; | ||
cin >> input; | ||
|
||
while(input != 0) { | ||
getPrime(); | ||
cin >> input; | ||
} | ||
} |