• 문제 : http://acm.kaist.ac.kr/2008/problems/B_6174.pdf

  • 입력값
  • 3
    6174
    1789
    2005

  • 출력값
  • 0
    3
    7 

  • 소스코드(파일)

  • 소스코드
  1. Favicon of http://gihyangkang.tistory.com BlogIcon Gk 2009.07.26 23:18

    이게 평이 극이더군요. 저는 재밌게봤는데 옆에 친구는 뭥미?라는반응~

  2. Favicon of http://najsulman.tistory.com BlogIcon 냐옹이 2009.08.31 23:15

    와우 멋진 문제네요... 퍼가도 되나요...?

  3. Favicon of http://najsulman.tistory.com BlogIcon 냐옹이 2009.09.01 09:28

    감사합니다^^;

  • 문제 : http://acm.kaist.ac.kr/2008/problems/A_Decryption.pdf

  • 입력값
  • 3
    asvdge ef ofmdofn
    xvssc kxvbv
    hull full suua pmlu

  • 출력값
  • f
    v
    ?

  • 소스코드(파일)

  • 소스코드
몇달째 Python만 손대다보니 C, C++ 문법조차 다 잊어버린 상황.
다시금 C, C++ 감을 찾기위해 Programming Challenges 책을 꺼내들었다.
심심할때마다 처음부터 차근차근 하나씩 풀어가기 위해.
처음으로 풀어본 문제는 예전에도 이미 한번 풀어본 적 있는 '3n+1 Problem'.
아직 이 문제를 효율적으로 풀 수 있는 알고리즘을 제대로 이해하지 못해서 직관적인 방법으로 풀었던니 실행시간이 너무 길다.(최단시간 0.008초, 내껀 0.828초...-_-)
효율적인 알고리즘을 공부 한 뒤에 다시 풀어봐야지...~_~

* 문제

* C 버전 소스코드

* C++ 버전 소스코드
  1. Favicon of http://jjackq.tistory.com BlogIcon 잭크 2008.10.30 14:09

    크크.. acm?

    • Favicon of https://ryuisaka.tistory.com BlogIcon RyuiSaka 2008.11.02 05:57 신고

      ACM...솔직히 내년에 다시 나가보고싶은 심정이예요...;ㅅ;

  2. Favicon of http://emulboy.com BlogIcon EmulBoy 2008.11.01 03:13

    뭐야 이 외계어... 무서워....

문제 : http://www.programming-challenges.com/pg.php?page=downloadproblem&probid=110502&format=html

Status : Solved
#include <iostream> using namespace std; unsigned int reverse(unsigned int input); int main(void) { unsigned int numberOfTestcase, input, i; cin >> numberOfTestcase; for(i = 0; i < numberOfTestcase; i++) { int count = 0; cin >> input; if(input == reverse(input)) { cout << 0 << " " << input << endl; } else { while((input = input + reverse(input)) != reverse(input)) { count++; } cout << ++count << " " << input << endl; } } return 0; } unsigned int reverse(unsigned int input) { unsigned int result = 0; while(input > 0) { result *= 10; result += input % 10; input = input / 10; } return result; }
  1. Favicon of http://jjackq.tistory.com BlogIcon 잭크와콩나무 2007.08.24 17:14

    굿 잡!

 

문제풀이 시간 : 10분(코딩 포함)
Solved 받아낼때까지 걸린 시간 : 1시간

그동안 Wrong Answer로 일관하던 Programming Challenges 로봇이 드디어 'Solved'를
뱉어냈다;;
문제는 경계값도 아니고 입력문제도 아니고 기본자료형의 최대크기문제???
Visual C++에서는 int형을 4바이트로 처리하기때문에 1,000,000이라는 숫자를 다룰 때 문제가
없지만 Programming Challenges의 로봇이 사용하는 컴파일러는 아마도 int형을 2바이트로
처리하는듯 하다.
그래서 65535를 넘어가면 문제를 일으켜서 'Wrong Answer'를 뱉어낸것 같다.
하지만 Runtime이 3초가 넘는걸 보면 알고리즘을 엄청나게 비효율적으로 설계한듯;;
Best Time이 0.008초로 나와있는데....대체 어떻게 알고리즘을 설계했길래 저런 시간이
나올 수 있는겐지;;
암튼 오랫동안 답을 얻지 못했던 문제를 풀어서 뿌듯하다.(물론 오래전에 문제를 풀긴 했으나
로봇덕분에 삽질을 계속 했었다;)

  1. Favicon of https://dogbob.tistory.com BlogIcon dogbob 2007.07.23 03:41 신고

    오... 저런 문제점도 있구나 -_-;;

    역시 배울 게 많은데...ㅋㅋ

  2. 아아아 2008.12.12 16:39

    코드 지금 그대로 쓰니까 롱앤서떠요 ㅛ

ACM_BeeHive.cpp

Source Code

B.in

Sample Test Case



문제 : http://cv.chonbuk.ac.kr/~alps/problem/icpc2004/2004ob.pdf

푼지 꽤 오래 된 문제.
이리저리 머리를 굴려봤지만 결국 술마시고 나서 경섭군 생각대로 막 코딩 하니까 답이
나왔던 문제.
음주코딩의 위대함을 보여줬던 문제.
결국 관건은 점화식을 세울 수 있느냐 없느냐였다.
입력은 B.in으로 받고 출력은 콘솔로 하도록 만들어놨음.
  1. Favicon of http://jhiz.com BlogIcon [=J=] 2007.07.16 01:08

    음주는 생각보다 많은걸 가능하게 하는거지..

A.in

Sample Test Case


문제 : http://cv.chonbuk.ac.kr/~alps/problem/icpc2004/2004oa.pdf

A게 답게 쉬웠던 문제.
예외처리는 안했음.
귀찮아서.

gift1.cpp

Source Code

gift1.in

Sample Input



영어문제는 항상 해석하는게 귀찮다;;
문제 자체는 쉬움.
----

Greedy Gift Givers

A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts of money. Each of these friends might or might not give some money to any or all of the other friends. Likewise, each friend might or might not receive money from any or all of the other friends. Your goal in this problem is to deduce how much more money each person gives than they receive.

The rules for gift-giving are potentially different than you might expect. Each person sets aside a certain amount of money to give and divides this money evenly among all those to whom he or she is giving a gift. No fractional money is available, so dividing 3 among 2 friends would be 1 each for the friends with 1 left over -- that 1 left over stays in the giver's "account".

In any group of friends, some people are more giving than others (or at least may have more acquaintances) and some people have more money than others.

Given a group of friends, no one of whom has a name longer than 14 characters, the money each person in the group spends on gifts, and a (sub)list of friends to whom each person gives gifts, determine how much more (or less) each person in the group gives than they receive.


IMPORTANT NOTE

The grader machine is a Linux machine that uses standard Unix conventions: end of line is a single character often known as '\n'. This differs from Windows, which ends lines with two charcters, '\n' and '\r'. Do not let your program get trapped by this!


PROGRAM NAME: gift1


INPUT FORMAT

Line 1: The single integer, NP
Lines 2..NP+1: Each line contains the name of a group member
Lines NP+2..end: NP groups of lines organized like this:
The first line in the group tells the person's name who will be giving gifts.
The second line in the group contains two numbers: The initial amount of money (in the range 0..2000) to be divided up into gifts by the giver and then the number of people to whom the giver will give gifts, NGi (0 ≤ NGi ≤ NP-1).
If NGi is nonzero, each of the next NGi lines lists the the name of a recipient of a gift.

Ad Hoc Problems

`Ad hoc' problems are those whose algorithms do not fall into standard categories with well-studied solutions. Each ad hoc problem is different; no specific or general techniques exist to solve them.

Of course, this makes the problems the `fun' ones, since each one presents a new challenge. The solutions might require a novel data structure or an unusual set of loops or conditionals. Sometimes they require special combinations that are rare or at least rarely encountered.

Ad hoc problems usually require careful reading and usually yield to an attack that revolves around carefully sequencing the instructions given in the problem.

Ad hoc problems can still require reasonable optimizations and at least a degree of analysis that enables one to avoid loops nested five deep, for example.

More ad hoc problems appear on this web site than any other kind of problem. Always be ready for an ad hoc problem if you can not classify a problem as one of the other standard types (to be listed later).

  1. 뿌우 2007.07.10 13:50

    땡큐

+ Recent posts