전체 글61 [C/Baekjoon] 백준 1193번(8-6) : 분수찾기 https://www.acmicpc.net/problem/1193 #include int main() { int x; scanf("%d",&x); //1/12/321/1234/54321/... =분자 //1/21/123/4321/12345/... =분모 //몇 번째 행인지 int r = 1; while(1) { if(r*(r+1)/2 >= x) break; //1~r까지의 합 r++; } int a = (r-1)*r/2; int b = x - a; int c = r - b +1; if(r%2 == 0) { printf("%d/%d",b,c); } else if(r%.. 2025. 2. 2. [C/Baekjoon] 백준 2292번(8-5) : 벌집 https://www.acmicpc.net/problem/2292#include int main() { int n; scanf("%d",&n); int i = 1; int last = 1; while(n>last) { last += 6*i; ++i; } printf("%d",i); return 0;}[주목할만한 부분]원자 구조처럼 생각해보자!(전자를 n개씩 가진 전자껍질)[원자핵] : 1[1주기] : 2 3 4 5 6 7 ->6개[2주기] : 8 9 10 11 12 13 14 15 16 17 18 19 ->12개[3주기] : 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 -.. 2025. 2. 2. [C/Baekjoon] 백준 11005번(8-2) : 진법 변환 2 https://www.acmicpc.net/problem/11005 #include #include int main() { int n,b; //1000000000 char my[100]; int index = 0; scanf("%d %d",&n,&b); while(n != 0) { int re = n%b; //나머지 if(re [주목할만한 부분]이전 문제인 진법 변환 1을 변형하면 된다.n이 0이 되기 전까지(=n 전체를) n%b로 10보다 작으면 문자로, 10이상은 A~Z로 표현한다.while문이 끝나면 가장 낮은 자릿수부터 앞에 들어가게 되므로, 결과 배열을 뒤집는다. 2025. 1. 26. [C/Baekjoon] 백준 2563번(8-1) : 진법 변환 https://www.acmicpc.net/problem/2745#include #include #include int main() { char input[10000]; //주어진 수 int B; //B진수 int result = 0; scanf("%s %d",input,&B); for(int i = 0; i= '0' && input[i] = 'A' && input[i] [주목할만한 부분]이제 math.h를 include 한다.pow(a,b)는 a^b (a의 b거듭제곱)을 뜻하는 math함수이다. 2025. 1. 23. [C/Baekjoon] 백준 2563번(7-4) : 색종이 https://www.acmicpc.net/problem/2563#include int main() { int num; scanf("%d",&num); int hap = 0; //(0,0)좌표에서부터 시작하는 배열이라고 생각하자! 먼저 차지한 사람이 임자인 방 100X100개이다. //공실일 경우 0, 들어올 경우 1이다. int chk[100][100] = {0}; for(int i = 0; i [주목할만한 부분]이런 식이라면 어떨까?좌표평면을 이런 배열이라고 생각하는 것이다![0][0] ~ [99][99], 총 100x100의 방이 존재한다. 이 문제는 선착순으로 방을 차지하는 문제라고 생각하자. 100x100의 공간에서, 1x1의 네모 한 칸 한 .. 2025. 1. 22. [C/Baekjoon] 백준 25206번(6-8) : 너의 평점은 https://www.acmicpc.net/problem/25206#include #include int main() { double hap = 0.0; //과목합(분자) int count = 0; //학점총합(분모) for(int i = 0; i [주목할만한 부분]배열을 비교할 때에는 strcmp(a,b)를 이용한다. 0이면 a와 b가 같다는 뜻이다.졸시뮬 엑셀 함수와 상당히 유사하다.https://r-pizzza.tistory.com/14 학점 계산기 , 졸업시뮬레이션 구글 스프레드시트 배포https://docs.google.com/spreadsheets/d/1afMKEcyL85-z0a8o_nYl6-no-PMLayM0mmcZSGL2qjk/edit?usp=sharing .. 2025. 1. 19. 이전 1 2 3 4 5 6 7 8 ··· 11 다음