From c0aa686683663971b939f0ae217d373eaa354885 Mon Sep 17 00:00:00 2001 From: Familia Date: Mon, 3 Nov 2008 21:02:44 -0500 Subject: [PATCH] 120 - Stack of flapjacks (Ad-hoc) --- 120 - Stacks of flapjacks/120 | Bin 0 -> 26038 bytes 120 - Stacks of flapjacks/120.cpp | 61 ++++++++++++++++++++++++++++++++++++++ 575 - Skew Binary/575.2 | Bin 0 -> 11703 bytes 575 - Skew Binary/575.2.cpp | 45 ++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100755 120 - Stacks of flapjacks/120 create mode 100644 120 - Stacks of flapjacks/120.cpp create mode 100755 575 - Skew Binary/575.2 create mode 100644 575 - Skew Binary/575.2.cpp diff --git a/120 - Stacks of flapjacks/120 b/120 - Stacks of flapjacks/120 new file mode 100755 index 0000000000000000000000000000000000000000..f03c996428c65c4602b78871e833615ddb1db947 GIT binary patch literal 26038 zcwX&%dtemR_5bW<5(ZhxBGCrqiva@#k&uKC5~yu>j2d~xJQP73H@i!Ab+fzOorPda zi-uIzb^TI=s%^E1kMb3(;Dh>Y>9-Lm5A|oG<=0Y6{Zgf}F+mU`1QOWqIrlL$``}@u z-+z9;fyvD0-gD1A_uO;OJ$H8I{!pHMqse3v_+b_@1VsLaM5zR>VmVDO5%L5{7$b}p zt`)KfhI0kbz)1?gnThmpW?&xRlKUYa&cT2Ovphyh4=f93R)HYkiRA?=%P)j;GvveB z1PQO11yV2O!>y1D`MHpXXACf&S*#8`Z-z2AL*01h0nRhzRsB+ zf%9s{`zkmsa9+X6@M8d+xdPP<^10HG_YEQO(0h>{{n+&~c10Qc!#R{;lnG_bhI5Fa z+~tOQ>^GDb>q7o0hv~XuBM_rp$Se4he&!cvecU?YOjrM$$1O9KRo=T*NIJ?nKND@^ z&lw&rP~6OfA7ZBXd6s`2%m1C3;@cU%mEkKH78tH(*ed8p9-P-CVF#=4n~a_hfermA zexLDsg~@v_%iqT6H#1)MGQ5E0-_7tumj5$`|H$$y8GeiLU(4_Z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S=CPUC3oAR%)1kff@r&e0jjxr`oxHIqw{ow&UDQG7mNl9>DH_?sV4_ zCp*6?>dBbUMH3UJ*}h1gu4BmFr0JsCiA;}_Gnv-$WRrK_rXi?TW)e(8uZN>1=u=#v zMvt>^{*MlZa|B(J>LF0|Uf40wMcz4>kQIaeX1jc0A;A{0OO2}&x};@cYUa?qK7Ze*<+Nc* zLXboiUaYS%(5peXjjaEbQDPssL0G^e^dcHgE5W6p7&3&*b=(KmbQIIo4s}^yOYP?i zj?oD@s5@l-oVi47lo|**6?K{4DezT8f`>fk1TdFvDV!Q*lsDS$bzb_Gu&sQP;?DE= zqcVNLTs14nRW!P(i%BEEx#xNCNJWzz?!}9p0jJka)kar57#&PfFjR)|FUuD*D$}&x z!5>3>UDJXYidzhxWcKV+`ydxelaTq4Y4`np_l0^^~yMp5@n8cAp0_k@C9 zW4-Q9jSNzr*&D-lK1tQ^ClG0Z%5w5E0uB<*8I}BNBL}bZ>#PqIcWGH^0WOREc5s;? V@4W@}O#=OyhsU-Th_IIk{{xBpgNXnD literal 0 HcwPel00001 diff --git a/120 - Stacks of flapjacks/120.cpp b/120 - Stacks of flapjacks/120.cpp new file mode 100644 index 0000000..ed3f92b --- /dev/null +++ b/120 - Stacks of flapjacks/120.cpp @@ -0,0 +1,61 @@ +/* + Problem: 120 - Stack of flapjacks + Author: Andrés Mejía-Posada + (http://blogaritmo.factorcomun.org) + + */ + +using namespace std; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(){ + + string s; + while (getline(cin, s)){ + stringstream sin(s); + + vector v, sol; + for (int x; sin >> x; v.push_back(x), sol.push_back(x)); + sort(sol.begin(), sol.end(), greater()); + + cout << v[0]; + for (int i=1; i llevo){ + if (i+1 < n) cout << i+1 << " "; + reverse(v.begin()+i, v.end()); + if (llevo+1 < n) cout << llevo+1 << " "; + reverse(v.begin()+llevo, v.end()); + } + llevo++; + } + cout << "0\n"; + } + return 0; +} diff --git a/575 - Skew Binary/575.2 b/575 - Skew Binary/575.2 new file mode 100755 index 0000000000000000000000000000000000000000..1394f08226286c52bb2f24d391f4602a7a224dfd GIT binary patch literal 11703 zcwW_74{%(?dEa+>lFqR#oooTZ5I7Oru?d!Rwq#pS8X5W7RxE7clN=jto=N9SAcv4fSM7k}8M+T$rhcbcmBC8MhEBkDZR`xYPvW z>+jn?_uidF5De3qzMH+>-|laBzx{Ui+uir}KBI5FrfEz)9#+K&ogCM_9q`XJi}()a zXI{3HEn%NyH5|k30|$<0fUAb5!&OllaL4^fhg$%=K&DBmcqlJie*uzCa@LHUn}c6PYZ zZ=>`X9#wu@JT}x8k1UVJ64|lVOtN)_h$oRr_6?f{Io~7mc;Oo1NR^k%vM6mH+!Yef zhpU%7uZ*jOn*-MbSI2~YE|X~s*oQxQ1*ZNWIX)w?)7#>i3)djSKFMDoc~qx%{nagm zNe+@f^X*#CGn?L=Z292aoTkU?diM6-b+n>L_8sY8!$jMjl=ymy-;qLmS>pW?Una4S zIgcOi+6uf@hHsSol@iaBcuL~GsulR6EdTE`fx9IBq2#|M`P-@lZjb`-YfAD ziN_?qP4XKhzFXq;5+9TJRf+!thLc%a6t@zksG@rUGL(#GjF_x^bvQYa3Z*The^Zzz z+G}FTjEUl{j^0GfmYIU~%5W^f1L@36QUya5qQ%NZTWxL)4)q2*%wVTE5HJlP(mEwl zMXl@HqV})f8cYT$i#a?tW~QukCYcDuWA)F12?Jd0~1$p%L?I4p0gk7Q)z{6D7 z18d?b`_;f{Jj87Se$Q)SzWU+%m+YNO*2X7_;LH;;y&cXMi_Ieo)$9>*nQLQn$l_e* z;?q=7^Z%!Z@2Vy%)GGP*vV&fdtV{A4=1@(wm`l|Q#2l%Hk@5l8qM#=7!EGiVbNg!Y zF=zbbBi|zOVI!83kCJa79}=~b4};l3K3cSfd>G+BARjI0CLacS9r-Yx8_9=&edNQ4 z^^*_dK0rQa%|`d}_H#@cj*j#8b4;3! z9^mZ<4*d4ciGRzzb+&(CY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>820*2A$;92PqlJOpgyu6{v^GQZa z&|a}B4U>=@F+<_7mB~1LO0Uf>y@xi#grpm7m#89>G@~dtZn>wSG%rJ_#xV*XyX7m* zQp36Zskn-EiN0r1XeuS{r_F*oGEzykzA7af+PZ0T(3~l!7*{l~*eAa~cuB)%W6e5f zzL3Ngf0sDZHNEa`*M+yTmc{Ll*D}{_zY1Z?uI(XB-oGPdB&-jgqNo=Wk=H@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define D(x) cout << #x " is " << x << endl + +int main(){ + + string s; + while (cin >> s && s != "0"){ + reverse(s.begin(), s.end()); + int ans = 0; + + for (int i=0, b=1; i