알고리즘/solved.ac

    [class2] (백준 2292) 벌집

    문제 위의 그림과 같이 육각형으로 이루어진 벌집이 있다. 그림에서 보는 바와 같이 중앙의 방 1부터 시작해서 이웃하는 방에 돌아가면서 1씩 증가하는 번호를 주소로 매길 수 있다. 숫자 N이 주어졌을 때, 벌집의 중앙 1에서 N번 방까지 최소 개수의 방을 지나서 갈 때 몇 개의 방을 지나가는지(시작과 끝을 포함하여)를 계산하는 프로그램을 작성하시오. 예를 들면, 13까지는 3개, 58까지는 5개를 지난다. 입력 첫째 줄에 N(1 ≤ N ≤ 1,000,000,000)이 주어진다. 출력 입력으로 주어진 방까지 최소 개수의 방을 지나서 갈 때 몇 개의 방을 지나는지 출력한다. 제한 예제 입력 1 복사 13 예제 출력 1 복사 3 힌트 출처 ICPC > Regionals > Asia Pacific > Korea ..

    [class2] (백준 2231) 분해합

    #include #include int main() { int input,place; int n = 1; int result = -1; scanf("%d",&input); place = 1000000; while(1) { if(input/place != 0) break; place/=10; } while(1) { if(place/10==0) break; place/=10; n++; } int checknum; int temp; for(int i = input - 9*n;i0;j--) { temp=i/pow(10,j-1); checknum+=temp%10; } if(checknum==input) { result=i; break; } } if(result==-1) printf("0\n"); else prin..

    [class2] (백준 10250) ACM 호텔

    #include int main() { int testnum; int w,h,n; int temp; scanf("%d",&testnum); while(testnum-- > 0) { scanf("%d %d %d",&h,&w,&n); temp = n%h==0 ? h:n%h; printf("%d\n",temp*100+((n-1)/h+1)); } return 0; }

    [class2] (백준 4153) 직각삼각형

    #include int main() { int len[3]; int temp; while(1) { scanf("%d %d %d",&len[0],&len[1],&len[2]); if(len[0]==0&&len[1]==0&&len[2]==0) break; for(int i = 0;i

    [class2] (백준 1085) 직사각형에서 탈출

    #include int min(int n1, int n2) { if(n1