-
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
36 changed files
with
784 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,9 @@ | ||
#include <stdio.h> | ||
|
||
int main(){ | ||
int A, B; | ||
scanf("%d %d", &A, &B); | ||
printf("%d", A+B); | ||
|
||
|
||
} |
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,34 @@ | ||
#include <stdio.h> | ||
|
||
int fibonacci(int n); | ||
|
||
int zero=0; | ||
int one=0; | ||
|
||
int main(){ | ||
int T; | ||
char A[3]; | ||
scanf("%d", &T); | ||
for(int i=0; i<T; i++){ | ||
while(scanf("%[^\n]", A) != EOF){ | ||
k = fibonacci(N); | ||
printf("%d %d %d\n", k, zero, one); | ||
zero = 0; | ||
one = 0; | ||
} | ||
} | ||
} | ||
|
||
int fibonacci(int n){ | ||
if(n=0){ | ||
zero++; | ||
return 0; | ||
} | ||
else if(n==1){ | ||
one++; | ||
return 1; | ||
} | ||
else{ | ||
return fibonacci(n-1)+fibonacci(n-2); | ||
} | ||
} |
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,22 @@ | ||
#include <stdio.h> | ||
|
||
int main(){ | ||
int T; | ||
int a, b; | ||
scanf("%d", &T); | ||
for(int i=0; i<T; i++){ | ||
scanf("%d %d", &a, &b); | ||
int num = 1; | ||
for(int j=0; j<b;j++){ | ||
num = (num * a)%10; | ||
} | ||
if(num == 0){ | ||
printf("10\n"); | ||
} | ||
else{ | ||
printf("%d\n", num); | ||
} | ||
} | ||
|
||
return 0; | ||
} |
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,22 @@ | ||
#include <stdio.h> | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int N; | ||
cin >> N; | ||
int Y=0, K=0, YS, KS; | ||
for(int i=0; i<N; i++){ | ||
Y=0; | ||
K=0; | ||
for(int j=0; j<9; j++){ | ||
cin >> YS >> KS; | ||
Y += YS; | ||
K += KS; | ||
} | ||
if(Y > K) cout << "Yonsei\n"; | ||
else if(Y < K) cout << "Korea\n"; | ||
else cout << "Draw\n"; | ||
} | ||
} |
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,16 @@ | ||
#include <stdio.h> | ||
|
||
int main(){ | ||
|
||
int T, d; | ||
scanf("%d", &T); | ||
for(int i=0;i<T;i++){ | ||
int x = 0; | ||
scanf("%d", &d); | ||
while(x+x^2<d){ | ||
x++; | ||
} | ||
printf("%d\n", x-1); | ||
} | ||
return 0; | ||
} |
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,19 @@ | ||
#include <stdio.h> | ||
#include <iostream> | ||
#include <istream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int N, min, max; | ||
cin >> N; | ||
int num[N] = {0,}; | ||
for(int i=0; i<N; i++) cin >> num[i]; | ||
min = num[0]; | ||
max = num[0]; | ||
for(int i=1; i<N; i++){ | ||
if(num[i] < min) min = num[i]; | ||
if(num[i] > max) max = num[i]; | ||
} | ||
cout << min << " " << max; | ||
} |
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,50 @@ | ||
#include <stdio.h> | ||
#include <stack> | ||
|
||
using namespace std; | ||
|
||
int main(void){ | ||
stack<int> s; | ||
int n; | ||
scanf("%d", &n); | ||
for(int i=0;i<n;i++){ | ||
char order[8] = {}; | ||
scanf("%s", order); | ||
if(order[0]=='p' && order[1]=='u'){ | ||
int x; | ||
scanf("%d", &x); | ||
s.push(x); | ||
} | ||
if(order[0]=='p' && order[1]=='o'){ | ||
if(s.empty()){ | ||
printf("-1\n"); | ||
} | ||
else{ | ||
printf("%d\n",s.top()); | ||
s.pop(); | ||
} | ||
} | ||
if(order[0]=='s'){ | ||
printf("%d\n", s.size()); | ||
} | ||
if(order[0]=='e'){ | ||
if(s.empty()){ | ||
printf("1\n"); | ||
} | ||
else{ | ||
printf("0\n"); | ||
} | ||
|
||
} | ||
if(order[0]=='t'){ | ||
if(s.empty()){ | ||
printf("-1\n"); | ||
} | ||
else{ | ||
printf("%d\n",s.top()); | ||
} | ||
|
||
} | ||
|
||
} | ||
} |
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,36 @@ | ||
#include <stdio.h> | ||
#include <queue> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int n; | ||
queue<int> q; | ||
scanf("%d",&n); | ||
while(n--){ | ||
char order[8]={}; | ||
scanf("%s",order); | ||
if(order[0]=='p' && order[1]=='u'){ | ||
int x; | ||
scanf("%d",&x); | ||
q.push(x); | ||
} | ||
if(order[0]=='p' && order[1]=='o'){ | ||
if(q.empty()) printf("-1\n"); | ||
else{ | ||
printf("%d\n",q.front()); | ||
q.pop(); | ||
} | ||
} | ||
if(order[0]=='s') printf("%d\n",q.size()); | ||
if(order[0]=='e') printf("%d\n",q.empty()); | ||
if(order[0]=='f'){ | ||
if(q.empty()) printf("-1\n"); | ||
else printf("%d\n",q.front()); | ||
} | ||
if(order[0]=='b'){ | ||
if(q.empty()) printf("-1\n"); | ||
else printf("%d\n",q.back()); | ||
} | ||
} | ||
} |
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,13 @@ | ||
#include <stdio.h> | ||
|
||
int main(){ | ||
int N, X; | ||
scanf("%d %d", &N, &X); | ||
for(int i=0; i<N; i++){ | ||
int k; | ||
scanf("%d", &k); | ||
if(k < X) printf("%d ", k); | ||
} | ||
} | ||
|
||
|
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,18 @@ | ||
#include <stdio.h> | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int N; | ||
cin >> N; | ||
for(int i=0; i<N; i++){ | ||
for(int j=1; j<2*N; j++){ | ||
if(i == N-1) cout << "*"; | ||
else if(j == N-i) cout << "*"; | ||
else if(j == N+i) cout << "*"; | ||
else if(j < N+i) cout << " "; | ||
} | ||
cout << "\n"; | ||
} | ||
} |
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,24 @@ | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int N; | ||
cin >> N; | ||
for(int i=0; i<N; i++){ | ||
if(i%2==0){ | ||
for(int j=0; j<2*N; j++){ | ||
if(j%2 == 0) cout << "*"; | ||
else cout << " "; | ||
} | ||
} | ||
else if(i%2==1){ | ||
for(int j=0; j<=2*N; j++){ | ||
if(j%2 == 1) cout << "*"; | ||
else cout << " "; | ||
} | ||
} | ||
cout << "\n" | ||
} | ||
|
||
} |
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,17 @@ | ||
#include <stdio.h> | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
|
||
int N, n, cycle = 0; | ||
cin >> N; | ||
n = N; | ||
while(1){ | ||
n = (n%10)*10+((n%10+n/10)%10); | ||
cycle++; | ||
if (N == n && cycle != 0) break; | ||
} | ||
cout << cycle; | ||
} |
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,10 @@ | ||
#include <stdio.h> | ||
|
||
int main(void){ | ||
char A[101]; | ||
while(scanf("%[^\n]", A) != EOF){ | ||
getchar(); | ||
printf("%s\n", A); | ||
} | ||
return 0; | ||
} |
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,39 @@ | ||
#include <stdio.h> | ||
#include <queue> | ||
|
||
using namespace std; | ||
|
||
int main(void){ | ||
int n; | ||
queue <int> q; | ||
scanf("%d", &n); | ||
int A[1000] = {0,}; | ||
int k = 1; | ||
for(int i=1; i<n+1; i++){ | ||
scanf("%d", &A[i]); | ||
} | ||
for(int i=1;i<n+1;i++){ | ||
if(A[i] == k){ | ||
A[i] = 0; | ||
k++; | ||
} | ||
} | ||
for(int i=n; i>0; i--){ | ||
if(A[i] != 0){ | ||
q.push(A[i]); | ||
} | ||
} | ||
while(q.size() != 0){ | ||
if(q.front() != k){ | ||
printf("Sad"); | ||
break; | ||
} | ||
else{ | ||
q.pop(); | ||
k++; | ||
} | ||
} | ||
if(q.size() == 0){ | ||
printf("Nice"); | ||
} | ||
} |
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,12 @@ | ||
#include <stdio.h> | ||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
int main(){ | ||
int A, B; | ||
cin >> A >> B; | ||
if(A > B) cout << '>'; | ||
else if(A<B) cout << '<'; | ||
else cout << "=="; | ||
} |
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,31 @@ | ||
#include <stdio.h> | ||
#include <math.h> | ||
|
||
int main(){ | ||
int a, b, c; | ||
long n, m; | ||
scanf("%d %d %d", &a, &b, &c); | ||
n = (-b + sqrt(b*b-4*a*c))/(2*a); | ||
m = (-b - sqrt(b*b-4*a*c))/(2*a); | ||
if((b*b-4*a*c) < 0){ | ||
printf("둘다틀렸근"); | ||
return 0; | ||
} | ||
else if(n>0 && m>0 && n != m){ | ||
int k = sqrt(n); | ||
int j = sqrt(m); | ||
|
||
if(k % 2 == 0 && j % 2 == 0){ | ||
printf("이수근"); | ||
return 0; | ||
} | ||
} | ||
else if(n != m){ | ||
printf("정수근"); | ||
return 0; | ||
} | ||
else{ | ||
printf("둘다틀렸근"); | ||
return 0; | ||
} | ||
} |
Oops, something went wrong.