题目1474: DotA

 

题目描述

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-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;
} 


 

 

posted @ 2013-03-25 12:44  xinyuyuanm  阅读(172)  评论(0编辑  收藏  举报