¹Ø±Õ£¨st£©¶þ½øÖÆ¿ò

2021-02-03 12:41

ÌôÕ½£ºA·Ç¸ºÕûÊýÁÐ±í£¬Í¨¹ýÔö¼Óÿ¸öÏîÄ¿µÄÊýÁ¿À´È·¶¨´´½¨Óë½á¹ûinteger-list×î½Ó½üµÄ¶þ½øÖÆ¿ò¡£Ê²Ã´ÊǶþ½øÖÆ¿ò£¿¶þ½øÖÆ¿òÖУ¬µÚÒ»ÐкÍ×îºóÒ»ÐÐÓÉ1λ×é³É£»µÚÒ»ÁÐ

½â´ð¶¯Ì¬

  • APL£¨Dyalog Extended£©£¬47 46 48×Ö½Ú {x¡û0??{x¡Ô

    • x?¡û?-?¡Í(1@1)¡ã¡ã¡ã??4?0¡Á?£ºx?????0}??£«~¡Á?} ÔÚÏßÊÔÓã¡
      Ò»¸ödfn£¬ËüÒÔÒ»¸öÏòÁ¿×÷ΪËüµÄÓÒ²ÎÊý¡£Èç¹ûÊäÈëÒѾ­ÊÇÒ»¸ö¶þ½øÖÆ¿ò£¬
      Êä³öÒ»¸ö0µÄÁÐ±í¡£
      ÔÚÒ»¸öfixÖ®ºó¼ÓÉÏ2¸ö×Ö½Ú¡££¨Ð»Ð»£¬°¢¶ûŵ£©
      Explanation {x¡û0??{x¡Ô

      • x?¡û?-?¡Í(1@1)¡ãÀ©Õ¹£©{x¡Ô

        • x?¡û?-?¡Í(1@1)¡ã¡ã??4?0¡Á?£ºx?????0}ÓÃ?+~¡Á?addµ÷ÓÃÏÂÃæµÄµÝ¹éº¯Êý£¡£¨signum£¨input£©£©µ½×ÔÉí£¨¶ÔÓÚ[0]£©µÄÌØÊâ´óСд?ת»»Îª¶þ½øÖƾØÕó?²¢½«ÊäÈëÁбí×÷Ϊright arg:If:0¡Á?¾ØÕóת»»ÎªÁã(1@1)¡ã?¡ã??4?ÿ±ß¼Ó1¡Í´Ó¶þ½øÖÆת»»?-?´ÓÊäÈëxÖмõÈ¥?¡û·ÖÅä¸øxx¡Ô

          • Èç¹ûxÓëÆä¾ø¶ÔÖµxÆ¥Å䣬Ôò·µ»Øx?????0£¬·ñÔòÌí¼ÓÒ»ÐÐÁ㣬ȻºóÖØÊÔ

            • Python 3.8£¬95 bytes f=lambda s£¬n=1£º£¨b:=[x-y´ú±íx£¬yÔÚzipÖУ¨£¨[n

              • n-1]+[n

                • 1]*£¨len£¨s£©-2£¬s£©]£©*£¨min£¨b£©gt£»=ÒÔsΪµ¥Î»µÄÖµ£¨b£º=¡­£©#¹¹ÔìÒ»¸öÐкÅÓës*£¨min£¨b£©#32£»[x-y±íʾx£¬yÔÚzip£¨¡­£¬s£©]£©]#È¡sÖÐÿ¶ÔÐкźÍÕûÊýµÄ²î[n

                  • n-1]#µÚÒ»ÐкÍ×îºóÒ»ÐеÈÓÚn

                    • n-1£»#ʾÀý£ºn=8£¬n

                      • n-1=8

                        • 7=0b1000

                          • 0b0111=0b1111=15+[n

                            • 1]*£¨len£¨s£©-2£©#ÖмäÐÐÊÇn

                              • 1#ʾÀý£ºn=8£¬n

                                • 1=8

                                  • 1=0b1000

                                    • 0b0001=0b1001=9£¨¡­£©*2#Öظ´´ËÁбíÁ½´ÎÒÔ»ñµÃµÚÒ»ÐУ¬#zip½«ºöÂÔËùÓжîÍâÔªËØ

                                      • 05AB1E£¬25 21 18 bytes -4×Ö½Ú£¬¸Ðл¿­ÎÄ¡¤¿Ë³ɭ£¡
                                        [NoDlt£»#decrement Id#°´ÓëÊäÈëÏàͬ³¤¶ÈµÄ1Áбí#ɾ³ýÇ°2¸öÔªËØs#swap to 2**N-1¡£##»·ÈÆ1ÁбíÒÔ»ñµÃÏàͬµÄÐÂÁÐ±í³¤¶È×÷ΪÊäÈë#=gt£»[2**N

                                        • 2**N-1£¬2**N

                                          • 1£¬¡­£¬2**N

                                            • 1µÄ¶þ½øÖÆÍø¸ñ£¬2**N

                                              • 2**N-1]I-#´Ó¶þ½øÖÆÍø¸ñÖмõÈ¥ÊäÈëÁбíÔªËØW#È¡×îСֵ¶ø²»µ¯³öÁбíd#Èç¹ûÕâÊǷǸºµÄ##´òÆÆÎÞÏÞÑ­»·²¢Òþʽ´òÓ¡Áбí

                                                • JavaScript£¨ES6£©£¬Èç¹ûÊäÈëÒѾ­ÊǶþ½øÖÆ¿ò£¬Ôò72×Ö½Ú Êä³ö0µÄÁÐ±í¡£
                                                  a=gt£»/-/.test£¨b=a.map£¨£¨v£¬i£©=lt£»gt£»//a[]=input array£¨g=k=gt£»//ÏÂmap£¨£©µÄ½á¹û£¬¶ÔÓÚa[]ÖÐλÖÃi´¦µÄÿ¸öÖµv:£¨i/a[i+1]£¿//Èç¹ûÕâ¼È²»ÊǵÚÒ»ÏîÒ²²»ÊÇ×îºóÒ»Ïî//£¨¼´i²»µÈÓÚ0²¢ÇÒ¶¨ÒåÁË[i+1]£©£ºk^//ʹÓô¹Ö±±ß¿òk/4lt£»1//ÀýÈç0b111111 XOR£¨£¨0b111111gt£»2£©lt£»1£©=0b100001://·ñÔò£ºk//ʹÓÃˮƽ±ß½ç£¨¼´È«Î»ÑÚÂëk£©£©-v//subtract v£©//end of map£¨£©£¿//Èç¹ûÓмõºÅ£ºg£¨k-~k£©//ÓÃ2*k+1ÔÙÊÔÒ»´Î£º//·ñÔò£ºb//success:return b[]£©£¨1£©//ÓÃk=1

                                                  • carbon³õʼµ÷ÓÃg£¬39 37 bytes ?1¦Æ??1¦È¦Çw‹}?¦Ç??¡Ü?¦Æ?e¦È??£¥¦Ë¦Ë?l¦È¨’¦Æ¦Æ???¦Æ¦Ç?i¦Ç ÔÚÏß³¢ÊÔ£¡Á´½Óµ½Ïêϸ°æ±¾µÄ´úÂ롣˵Ã÷£ºÎÒÊÔ×ÅÖ±½Ó¼ÆËãÕýÈ·µÄºÐ×Ó´óС£¬µ«ÊÇÓÐÌ«¶àµÄ±ßÔµÇé¿ö¡£
                                                    ?1¦Æ ´ÓÒ»¸ö¿í¶ÈΪ1µÄºÐ×Ó¿ªÊ¼¡£
                                                    ??1¦È¦Ç ¿´Õâ¸öºÐ×ÓÊÇ·ñÄÜÈÝÄÉÊäÈë¡£
                                                    w‹}?¦Ç? Öظ´Ö±µ½ÕÒµ½×ã¹»´óµÄºÐ×Ó¡£
                                                    ¡Ü?¦Æ Ôö¼ÓºÐ×ӵĴóÐ £
                                                    ??e¦È???¦Ë?l¦È¨’¦Æ¦Æ??¦Æ¦Ç ¼ÆËãºÐ×Ó²¢¼õÈ¥Ô­À´µÄ´óСinput.
                                                    ?i¦Ç Êä³ö×îÖÕÔöÁ¿¡£

                                                    • Python 3.8+£¬91 bytes f=lambda b£¬n=1:f£¨b£¬n*2£©if min£¨u:=r

                                                      • [£¨t:=2*n-1£©£¬b[2:]*0+n

                                                        • 1£¬t]-b£©<£»0·ñÔò´Ónumpy import* ²ÎÊýb±ØÐëÊÇÕûÊýµÄnumpyÊý×é¡£
                                                          Òò´Ë£¬²»ÒªÁª»ú³¢ÊÔ¡£
                                                          ʹÓÃnÖµ1£¬2£¬4£¬8£¬¡­£¬µÝ¹é£¬²¢¹¹Ôìarray
                                                          r

                                                          • [£¨t:=2*n-1£©£¬#µÚÒ»ÐÐb[2:]*0+n

                                                            • 1£¬#ÖмäÐУ¬ËùÓÐÖµ¾ùΪn

                                                              • 1£¬length=len£¨b[2:]£©t#×îºóÒ»ÐУ¬ÓëµÚÒ»ÐÐÏàͬ] Ϊ¶þ½øÖÆ¿ò£¬È»ºó·µ»Ø²»Ð¡ÓÚbµÄµÚÒ»ÐС£

                                                                • 05AB1E£¬25 31 25 26 bytes +6ÓÃÓÚÊäÈë[1,0£¬1]
                                                                  -6¸ÐлKevin Cruijssen
                                                                  +1ÐÞ¸´Á˵¥¸öÔªËØÁбí
                                                                  d?¡Þ¦ÅoIggt£»ylt£»?}?¦¤µÄ´íÎóI@P¹«Ë¾}Äã¿ÉÒÔÔÚÍøÉÏÊÔÊÔ£¡»òÕßÊÔÊÔËùÓеݸ×Ó

                                                                  • End

                                                                  ÃâÔðÉùÃ÷£º

                                                                  ±¾Ò³ÄÚÈݽö´ú±í×÷Õß±¾ÈËÒâ¼û£¬ÈôÒò´Ë²úÉúÈκξÀ·×ÓÉ×÷Õß±¾È˸ºÔ𣬸ÅÓëÇÙµºÍø¹«Ë¾Î޹ء£±¾Ò³ÄÚÈݽö¹©²Î¿¼£¬ÇëÄú¸ù¾Ý×ÔÉíʵ¼ÊÇé¿ö½÷É÷²Ù×÷¡£ÓÈÆäÉæ¼°Äú»òµÚÈý·½ÀûÒæµÈÊÂÏÇë×ÉѯרҵÈËÊ¿´¦Àí¡£