ZeroJudge - d583: 幼稚的企鵝 解題心得

(function(w,d,s,l,i)w[l]=w[l])(window,document,'script','dataLayer','GTM-KDKMGT');
(function(d, s, id) var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/zh_TW/all.js#xfbml=1&appId=668497826514848"; fjs.parentNode.insertBefore(js, fjs); (document, 'script', 'facebook-jssdk'));






if(BAHAID)
BAHAID = BAHAID.replace(/&/g, "&")
.replace(/, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");

BAHAIDlow = BAHAID.toLowerCase();

document.write('');

document.write('

');
document.write('');
document.write('');
document.write('');
document.write('

');

//document.write('
');
document.write('
');
document.write('
');
document.write('
');
document.write('
');
document.write('
');
document.write('
');
document.write('
');


else
document.write('
');
document.write('');
document.write('
    ');
    document.write('
  • 我要登入
  • ');
    document.write('
  • 註冊
  • ');
    document.write('
  • ');
    document.write('
');
document.write('
');


document.write('
');

document.write(' ');

(function()
var cx = 'partner-pub-9012069346306566:kd3hd85io9c';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
)();

service = new rsearch('rsearch');

if( BAHAID )
NOTIFY_getnum();
run30 = setInterval("NOTIFY_getnum()",60000);


function insideSecondaryfunc(frm, evt){
if( 0










googletag.cmd.push(function()
googletag.defineSlot('/1017768/AD2018032204', [1250, 160], 'div-gpt-ad-banner').addService(googletag.pubads());

window.DFP.setTargeting();

googletag.pubads().enableSingleRequest();
googletag.enableServices();
);

googletag.cmd.push(function() googletag.display('div-gpt-ad-banner'); );
document.cookie = 'ckBahaAd=0------------------------;path=/;expires=' + new Date().toDateString() + ' 23:59:59 UTC+0800;domain=.gamer.com.tw'










breadCrumbs(122, '', 'homeuid=inversion')








    breadCrumbs_listMenu(122, 0, 'homeuid=inversion')





    創作內容





    0 GP


    ZeroJudge - d583: 幼稚的企鵝 解題心得


    作者:Not In My Back Yard│2018-11-01 21:31:10│贊助:0│人氣:16

    題目連結:

    d583: 幼稚的企鵝





    題目大意:

    給定一個正整數 N (1 ≦ N ≦ 100, 000),代表接下來有 N 個數字。每個數字代表一隻企鵝的座號,保證不會重複,且座號一定介於 1 ~ N 。



    把企鵝座號由小排到大,並輸出。







    範例輸入:

    10

    9 5 10 4 3 6 1 2 7 8

    30

    30 29 28 27 26 25 10 11 12 13 15 14 16 19 18 17 20 24 23 22 21 8 9 7 6 5 3 4 2 1







    範例輸出:

    1 2 3 4 5 6 7 8 9 10

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30







    解題思維:

    因為編號一定是 1 ~ N ,而且又不會重複。所以一讀完數字 N 和那 N 隻企鵝的編號,就可以用迴圈從 1 跑到 N ,並輸出即可。








    本人的程式碼(放在CodePile)


    此次分享到此為止,如有任何更加簡潔的想法或是有說明不清楚之地方,也煩請各位大大撥冗討論。






    喜歡0
    收藏
    0
    引用
    0
    留言
    推上首頁



    檢舉








    引用網址:https://home.gamer.com.tw/TrackBack.php?sn=4181192

    All rights reserved. 版權所有,保留一切權利





    相關創作

    同標籤作品搜尋:程式題目解題心得





    ZeroJudge - c731: 走路時要算數學 解題心得




    ZeroJudge - c677: 銀河宮廟 解題心得




    ZeroJudge - c878: 107北二5.議會質詢紀錄 解題心得




    ZeroJudge - c705: Int32 to IPv4 解題心得




    ZeroJudge - c633: 基礎排序 #2-2 ( 質因數和 ) 解題心得


    留言共 0 篇留言




    Util.ChangeText('replys', Util.ChangeText.FLAG_LAZYLOAD|Util.ChangeText.FLAG_MAX_SIZE|Util.ChangeText.FLAG_BALA_PLAYER);

    我要留言提醒:您尚未登入,請先登入再留言


    0喜歡★inversion 可決定是否刪除您的留言,請勿發表違反站規文字。



    前一篇:ZeroJudge - ...

    後一篇:ZeroJudge - ...








    egg('.MSG-list8C img').each(function(elem)
    elem.className = elem.className + ' lazyload';
    );

    egg('.gallery-image').imageGallery();

    function deleteCreation(vCode)
    var content = egg('.MSG-list8C').html();
    var pattern = /]*?>/i;
    var html = '
    確定要刪除嗎?';
    var width = '200px';
    if(content.match(pattern))
    html += '
    ';

    var boxConfig =
    'closeButton': false,
    'css':
    'width': width

    ;

    egg.mutbox(html, '訊息',
    '確定': function()
    if(egg('#chkDelTruthImage:checked').size())
    egg('[name=delTruthImage]').val('yes');


    egg.cookie.del('ckHOME_CREATION','home.gamer.com.tw','/');
    egg.cookie.set('ckHOME_CREATION',vCode,'home.gamer.com.tw','/');
    document.getElementById('frmDel').submit();
    egg.lightbox.close();
    ,
    '取消': function()
    egg.lightbox.close();

    ,boxConfig);

    var buttonOk = egg('.BH-popbtns :button:eq(0)');
    if(buttonOk.size())
    buttonOk.get(0).focus();



    resizeImage(627);

    egg('.btnGp').click(function()
    $.mutbox('請先登入才能進行此動作', '訊息', '確定':function()location.href='https://user.gamer.com.tw/login.php';);
    );







    訂閱私訊


    作品資料夾


    ZeroJudge (136)


    未分類 (0)


    a12131625各位巴友
    小屋新增了些ACG資訊!歡迎來逛逛!看更多我要大聲說昨天17:01







    googletag.cmd.push(function() googletag.display('div-gpt-ad-1489070677458-0'); );



    (function(window, $)
    var $window = $(window);
    var $document = $(document);
    var $BH_slave = $("#BH-slave");
    var $BH_master = $("#BH-master");
    var $flySalve = $("#flySalve");
    var posY = $flySalve.position().top;
    var fad_style = document.getElementById("flySalve").style;
    var BH_wrapper_width = $('#BH-wrapper').width();
    var BH_topBar_height = $('.TOP-bh').height();
    $(window).on("scroll", function()
    posY = $BH_slave.height() - (fad_style.position === 'fixed' ? 0 : $flySalve.height());

    if ($document.scrollTop() > (posY + $BH_slave.offset().top - BH_topBar_height) && $BH_slave.height() < $BH_master.height())
    fad_style.position = 'fixed';
    fad_style.top = BH_topBar_height + 'px';
    if ($(window).width() < BH_wrapper_width)
    fad_style.left = (BH_wrapper_width - $BH_slave.width() - $document.scrollLeft())+'px';

    else
    fad_style.position = '';

    ).on("resize", function()
    fad_style.left = null;
    );
    )(window, jQuery);
















    face我們了解您不想看到廣告的心情⋯ 若您願意支持巴哈姆特永續經營,請將 gamer.com.tw 加入廣告阻擋工具的白名單中,謝謝 !【教學】





    The name of the picture黑色沙漠手遊伺服器是巴雷諾斯公會缺人名稱是GO歡迎大家查詢到後加入

    This page is only for reference, If you need detailed information, please check here
    The name of the pictureThe name of the picture

    Popular posts from this blog

    京昆高速公路

    【情報】本週珍珠商品重點:煉金時裝 + 艾港勞工宿舍!!

    【攻略】陳戈-謝勒汗智慧的古書 (完成)