題目1474: DotA

來源:互聯網
上載者:User
題目描述

DotA(Defence of the Ancients) is very popular in Zhejiang University.Now a new hero appears in DotA.This hero has a miraculous skill.If the target's HP n is an even number,then it will be cut in half after skill-using.Otherwise the targe's HP will plus one
after skill-using.Given a target's HP,we want to decrease the target's HP from n to 1 only with this new skill.

 


輸入

The input consists of multiple test cases.Each case contain one line with an integer n(1<n≤1000000000).

 


輸出

For each test case,output the target's HP's changing process on a single line.The HP values connect with '-' character.

 


範例輸入

5
21
 


範例輸出

5-6-3-4-2-1
21-22-11-12-6-3-4-2-1
 


提示 [+]

*** 提示已隱藏,點擊上方 [+] 可顯示 ***

 


來源

2013年浙江大學複試機試類比題

 

/**********************************   日期:2013-3-25*   作者:SJF0115*   題號: 題目1474: DotA*   來源:http://acmclub.com/problem.php?id=1474*   結果:AC*   來源:2013年浙江大學複試機試類比題*   總結:**********************************/#include<stdio.h>#include<string.h>int main(){long long int N;int first,i;//freopen("C:\\Users\\SJF\\Desktop\\acm.txt","r",stdin);while(scanf("%lld",&N)!=EOF){first = 1;printf("%lld",N);while(N > 1){if(N % 2 == 0){N = N / 2;}else{N = N + 1;}printf("-");printf("%lld",N);}printf("\n");}return 0;} 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.