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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值