KLDP Code Fest/Theme Coding
Á¡¼ö (¿©·¯ ¹ø Á¦ÃâÇϽŠºÐÀº ¸ðµÎ ÃÖÁ¾ ´ä¾È ±âÁØ)
ÄÚµå ÆÛÁñ Á¦ÃâÇϽŠ´ä
1. cdpark ´Ô ¶
#include <stdio.h>
#include <stdlib.h> #define h(x) x+(x>9?55:48) void o(int n) { n?o(n/N),putchar(h(n%N)):0; } int main() { o(strtol(X,0,M)); return 0; }
#include <stdio.h>
void o(int n) { n?o(n/N),putchar(n%N+(n%N>9?55:48)):0; } int main() { char *x=X; int n=0; do { n*=M; n+=*x<97?*x-48:*x-87; } while (*++x); o(n); return 0; }
2. mithrandir ´Ô ¶
#include <stdio.h>
#define b a/i #define c X[i] int main () { int a=0, i=0; while (c) { a *= M; a += (c <= 57)?c-48:c-87; i++; } i = 1; while (a / (i *= N)); while ((i/=N)>0) { putchar (b<=9 ? b+48 : b+97); a %= i; } }
3. ¼»óÇö ´Ô ¶
#include <stdio.h>
int main() { char *x = X; int s = 0, i = 1; do { s *= M; s += (*x-(*x<'a'?'0':'a'-10)); } while (*++x); do { i *= N; } while (i * N < s); while (i) { putchar(s/i+(s/i<10?'0':'a'-10)); s %= i; i /= N; } }
4. sliver ´Ô (¿ì½Â) ¶
#include <stdio.h>
void p(int v,int i) { v ? (p(v/N,1),v%=N,v += v<10 ? '0' : 'a'-10,putchar(v)) : 0; if(!i) { for(;X[i];i++) v = M*v + (X[i] <= '9' ? X[i]-'0' : X[i]+10-'a'); v ? p(v,1) : putchar('0'); } } int main() { p(0,0); }
5. yui ´Ô ¶
#include <stdio.h>
#define to_num( d ) ( ( d < '9') ? ( d - '0') : ( d - 'a'+10)) #define to_char( d ) ( (d > 10) ? ('a' + d - 10) : ( d + '0')) int main() { int v=0, i=0; while(X[i]){ v+=to_num(X[i]); v*=M; ++i; } v/=M; i=v; while (i > N) { int k = 1; while(v > N) { v= v/ N; k*=N; } putchar(to_char(v%N)); v = i - k*(v%N); i = v; v = i; } putchar(to_char(v%N)); }
6. Åä³¢±º ¶
#include<stdio.h>
int i,s; int Q() { return s % N + 48 + (s % N > 9) * 7 + (s / N ? s /= N, putchar(Q()), 0 : 0); } int main() { while( X[i] ) s = M * s + X[i] - (X[i++] < 64 ? 48 : 87); return putchar(Q()); }
7. ±âŸ Àâ´ã ¶±¦È÷ ª°Ô Â¥´Â »ç¼ÒÇÑ °í¹Î¸¸ ÇÏ´Ù°¡ °á±¹ ¸ø Á¦ÃâÇߴµ¥.. ±× ÁßÀÇ ÇÑ °¡Áö°¡, <stdio.h>º¸´Ù int putchar(int);¸¦ ¾²´Â ÆíÀÌ 1±ÛÀÚ ÁÙ´õ±º¿ä. -cwryu
int putchar();·Î Çϸé 4±ÛÀÚ ÁÙÀÏ ¼ö ÀÖ½À´Ï´Ù. C¿¡¼¸¸ Çã¿ëµÇ´Â.. -perky
¾Æ! ±× »ý°¢À» ¸ø Çß±º¿ä --Åä³¢±º
ª°Ô ¾²´Â°É Çغ¸Áú ¾Ê¾Æ ½À°ü´ë·Î Â¥¼ ³Â³×¿ä. Å×½ºÆ® Á» Çغ¸°í Àß µÇ±æ·¡ ±×³É Á¦ÃâÇß½À´Ï´Ù. ¾ÐµµÀû(?)ÀÎ ±æÀ̱º¿ä. ÈåÈå. -- yui
Åä³¢±º ´ÔÀÇ ÇÁ·Î±×·¥¿£ ¾à°£ À§ÇèÇÑ Äڵ尡 µé¾î ÀÖ½À´Ï´Ù. Q ÇÔ¼ö ³»ºÎ¿¡ s¿¡ ´ëÇÑ ÇÒ´çÀÌ ÀÖ½À´Ï´Ù. C ¾ð¾î ¹®¹ý¸¸À¸·Î´Â (s /= N) ºÎºÐÀÇ °è»êÀÌ ³ªÁß¿¡ µÉ °Å¶ó´Â º¸ÀåÀÌ ¾ø½À´Ï´Ù. - cdpark
³×. ÄÄÆÄÀϸ¸ µÇ°í Á¦´ë·Î ½ÇÇàµÇ´Â Áö¸¸ È®ÀÎÇ߱⠶§¹®¿¡ º¸ÀåÀº ÇÒ ¼ö ¾øÀ» °Ì´Ï´Ù. (gcc¿¡¼´Â µÇ¾úÁö¸¸ ¾îµð¼ ¾î¶² ÀÏÀÌ ÅÍÁú Áö ¾Æ¹«µµ ¸ð¸£´Â Æøź ÄÚµå...¶ö±î¿ä. Äð·°.) --Åä³¢±º
7.1. cdpark (¸¶°¨ÈÄ ¹öÁ¯ÀÇ °³·®ÆÇ1) ¶
int putchar();
void o(int n) { n?o(n/N),putchar(n%N+(n%N>9?55:48)):0; } int main() { char *x=X; int n=0; do { n=n*M+*x-48-(*x>64)*39; }while(*++x); o(n); } Åä³¢±º ´Ô ¹öÁ¯À» ºñ½ÁÇÑ ±ÔÄ¢(stdio.h Á¦°Å,...)À¸·Î °íÄ£°Íº¸´Ù 1 byte ª½À´Ï´Ù. ±×·¯³ª º¯¼ö´Â ¼¼°³. ½Ã»ó½Ä ÀÌÀü±îÁö ¸¸µé¾ú´ø ¹öÁ¯ÀÔ´Ï´Ù. submitÀº ¾È Çß°í..
7.2. cdpark (ultimate ÆÇ) ¶
int putchar();
void f(char *x,int n) { *x?f(x+1,n*M+*x-48-(*x>64)*39) :n?f(x,n/N),putchar(n%N+48+(n%N>9)*7):0; } int main() { f(X,0); } ÆÛÅ° ´ÔÀÌ ¿øÇÑ ¼Ò½º°¡ ÀÌ°Å°ÚÁÒ? º¯¼ö µÎ°³! Àü¿ªº¯¼ö ¾øÀ½! Á¡¼ö´Â ´ë·« 60 Á¡? -- cdpark
warningÀÌ ³ªµµ »ó°ü¾ø´Ù¸é ÇÔ¼ö¼±¾ð¾Õ¿¡ void¶û int»©µµ µÉµíÇÕ´Ï´Ù. -- byteme
´ëȸ ±ÔÄ¢¿¡ -c99 -Werror ¿É¼ÇÀÌ ÀÖ´ä´Ï´Ù. -- cdpark
ÃÊ°í¼ö´ÔµéÀÇ ¾ÏÈ£°°Àº ¼Ò½º¸¦ º¸°í ÀÖÀÚ´Ï ´«ÀÌ µ¹¾Æ°¡°í ¸Ó¸®°¡ ±úÁú °Í °°±º¿ä. ¼Ò½º¿¡ ´ëÇÑ Çؼ³À» µ¡ºÙ¿©ÁÖ¼ÌÀ¸¸é ÁÁ°Ú½À´Ï´Ù. --¼¼¹ú
¼»óÇö´ÔÀÇ Äڵ尡 °¡Àå ±âº»ÀûÀÎ ÇüŶó°í ÇÒ ¼ö ÀÖÀ» °Ì´Ï´Ù. ¸ÕÀú MÁø¼ö X¸¦ 10Áø¼ö·Î º¯È¯ÇÏ°í, ±× 10Áø¼ö¸¦ ´Ù½Ã NÁø¼öÀÇ ¼ö·Î º¯È¯ÇÏ´Â °Ì´Ï´Ù. ¼»óÇö´Ô ÄÚµåÀÇ Ã¹¹ø° do-while loopÀÌ 10Áø¼ö·Î º¯È¯ÇÏ´Â ÄÚµå°í, ¸¶Áö¸· while loopÀÌ ´Ù½Ã NÁø¼ö·Î º¯È¯ÇÏ´Â ÄÚµåÀÔ´Ï´Ù. (°¡¿îµ¥ do-while loopÀº NÁø¼ö·Î º¯È¯Çϱâ ÀüÀÇ ÁغñÀÛ¾÷)
´Ù¸¥ ºÐµéÀÇ Äڵ嵵 ±âº»ÀûÀ¸·Î °°Àºµ¥, ÄÚµå ±æÀ̸¦ ÁÙÀ̱â À§Çؼ loopÀ» recursionÀ¸·Î Ç¥ÇöÇÏ´Â ¹æ¹ýÀ» »ç¿ëÇÑ °Ì´Ï´Ù. (´ëºÎºÐÀÌ µÎ¹ø° ´Ü°è, NÁø¼ö·Î º¯È¯ÇÏ´Â Äڵ带 recursionÀ¸·Î Ç¥ÇöÇÏ°í ÀÖ½À´Ï´Ù.)
°³ÀÎÀûÀ¸·Î cdpark´ÔÀÇ ultimateÆÇÀº ƯÀÌ(?)ÇÏ°Ô »ý±ä ÄÚµå¶ó°í »ý°¢ÇÏÁö¸¸ ÇÁ·Î¼¼½º´Â µ¿ÀÏÇÕ´Ï´Ù. -- kane
|
Good fortune in love, as well as a better position. |