본문 바로가기

분류 전체보기351

[11051] 이항 계수 2 #include using namespace std;#define MAX 1001int bin_coef_DP(int n, int k);int C[MAX][MAX];int main(){int n, k;cin >> n >> k;cout 2018. 7. 23.
[11050] 이항 계수 1 #include using namespace std;int bin_coef_DC(int n, int k);int main(){int n, k;cin >> n >> k;cout 2018. 7. 23.
[1003] 피보나치 함수 #include #define MAX 40using namespace std;int memo_fib(int n);int main(){int n, testcase;cin >> testcase;for (int i = 0; i > n;if (n == 0)cout 2018. 7. 23.
[2749] 피보나치 수 3 #include using namespace std;int iterative_fib(long long n);int fib[1500000];int main(){long long n;cin >> n;cout 2018. 7. 23.
[2748] 피보나치 수 2 #include #define MAX 90using namespace std;long iterative_fib(int n);int main(){int n;cin >> n;cout 2018. 7. 23.
[2747] 피보나치 수 #include #define MAX 45using namespace std;int iterative_fib(int n);int main(){int n;cin >> n;cout 2018. 7. 23.
[1021] 회전하는 큐 #include #include using namespace std;int main(){deque dq;deque::iterator iter;int n, m, i, cnt = 0;cin >> n >> m;for (i = 1; i num;int index = 1;for (iter = dq.begin(); iter 2018. 7. 22.
[10866] 덱 #include #include #include using namespace std;int main(){deque dq;int i, num, testcase;string str;cin >> testcase;for (i = 0; i > str;if (str == "push_front"){cin >> num;dq.push_front(num);}else if (str == "push_back"){cin >> num;dq.push_back(num);}else if (str == "pop_front"){if (!dq.empty()){cout 2018. 7. 22.
[1158], [11866] 조세퍼스 문제 #include #include #include using namespace std;void Josephus(int n, int m);int main(){int n, m;cin >> n >> m;Josephus(n, m);return 0;}void Josephus(int n, int m){queue q;int i;for (i = 1; i 2018. 7. 22.
[1966] 프린터 큐 #include #include using namespace std;int main(){int i, testcase;cin >> testcase;for (i = 0; i > n >> m;for (int j = 0; j > a;q.push({ j, a });pq.push(a);}while (!q.empty()){int index = q.front().first;int val = q.front().second;q.pop();if (pq.top() == val){pq.pop();cnt++;if (index == m){cout 2018. 7. 22.
[10845] 큐 #include #include #include using namespace std;int main(){queue q;int i, testcase;string str;cin >> testcase;for (i = 0; i > str;if (str == "push"){int num;cin >> num;q.push(num);}else if (str == "pop"){if (!q.empty()){cout 2018. 7. 22.
[2504] 괄호의 값 #include #include #include using namespace std;int checkVPS(string str);int main(){string str;cin >> str;cout 2018. 7. 22.
[9012] 괄호 #include #include #include using namespace std;bool checkVPS(string str);int main(){string str;int testcase;cin >> testcase;for (int i = 0; i > str;if (checkVPS(str))cout 2018. 7. 22.
[10828] 스택 #include #include #include using namespace std;int main(){stack st;string str;int testcase;cin >> testcase;for (int i = 0; i > str;if (str == "push"){int num;cin >> num;st.push(num);}else if (str == "pop"){if (!st.empty()){cout 2018. 7. 21.
[4948] 베르트랑 공준 #include using namespace std;int main(){bool arr[246913] = { 0 };int i, j;arr[0] = arr[1] = true;for (i = 2; i num;if (num == 0)break;for (i = num+1; i 2018. 7. 21.
[1929] 소수 구하기 #include #include using namespace std;int main(){bool arr[1000001] = { 0 };vector suso;int num1, num2;int i, j;scanf("%d %d", &num1, &num2);arr[0] = arr[1] = true;for (i = 2; i 2018. 7. 17.
[2581] 소수 #include #include using namespace std;int main(){vector suso;int num1, num2, sum = 0;int i, j;cin >> num1;cin >> num2;for (i = num1; i 1){for (j = 1; j 2018. 7. 17.
[1978] 소수 찾기 #include #include using namespace std;int main(){vector v;int n, cnt = 0;cin >> n;for (int i = 0; i > num;v.push_back(num);}for (int i = 0; i 1){for (int j = 1; j 2018. 7. 17.
[1181] 단어 정렬 #include #include #include #include using namespace std;bool cmp(const string &a, const string &b){if (a.size() == b.size())return a n;for (int i = 0; i > str;v.push_back(str);}vector::iterator iter;sort(v.begin(), v.end(), cmp);v.erase(unique(v.begin(), v.end()), v.end());for (iter = v.begin(); iter != v.end(); iter++)cout 2018. 7. 14.
[1427] 소트인사이드 #include #include #include using namespace std;bool cmp(char &a, char &b){return a > b;} int main(){char c[10];cin >> c;sort(c, c+ strlen(c), cmp);cout 2018. 7. 14.